How can I use UUID to generate primary key value via annotation?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I use UUID to generate primary key value via annotation?

Jun Jason
Like @GenericGenerator in Hibernate.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How can I use UUID to generate primary key value via annotation?

Guy Rouillier-2
You don't mention which DBMS you are using.  PostgreSQL, for example, has built-in UUID support for newer versions.  You can generate the UUID from within the database, so you would not need to supply an annotation to do so.  Is this an acceptable approach?

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/6/2018 2:17:25 AM
Subject: How can I use UUID to generate primary key value via annotation?

Like @GenericGenerator in Hibernate.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How can I use UUID to generate primary key value via annotation?

Jun Jason
Hi, I'm using MySQL. Is there an annotation that I can use to generate UUID automatically for me?


Mailtrack Sender notified by
Mailtrack 08/07/18, 11:14:45 AM

On Tue, Aug 7, 2018 at 11:07 AM Guy Rouillier <[hidden email]> wrote:
You don't mention which DBMS you are using.  PostgreSQL, for example, has built-in UUID support for newer versions.  You can generate the UUID from within the database, so you would not need to supply an annotation to do so.  Is this an acceptable approach?

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/6/2018 2:17:25 AM
Subject: How can I use UUID to generate primary key value via annotation?

Like @GenericGenerator in Hibernate.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re[2]: How can I use UUID to generate primary key value via annotation?

Guy Rouillier-2
I'm not an expert on MySQL, but a quick search reveals MySQL has native UUID support:


So, I again have the same question as before.  Can you use the built-in support to create the primary key?  That's better than creating it in code and passing it in, and eliminates the need for any annotations.

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
Sent: 8/6/2018 11:15:41 PM
Subject: Re: How can I use UUID to generate primary key value via annotation?

Hi, I'm using MySQL. Is there an annotation that I can use to generate UUID automatically for me?


Mailtrack Sender notified by
Mailtrack 08/07/18, 11:14:45 AM

On Tue, Aug 7, 2018 at 11:07 AM Guy Rouillier <[hidden email]> wrote:
You don't mention which DBMS you are using.  PostgreSQL, for example, has built-in UUID support for newer versions.  You can generate the UUID from within the database, so you would not need to supply an annotation to do so.  Is this an acceptable approach?

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/6/2018 2:17:25 AM
Subject: How can I use UUID to generate primary key value via annotation?

Like @GenericGenerator in Hibernate.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re[3]: How can I use UUID to generate primary key value via annotation?

Guy Rouillier-2
Take a look at the @SelectKey annotation in the MyBatis User's Guide.

--
Guy Rouillier

------ Original Message ------
From: "Guy Rouillier" <[hidden email]>
Sent: 8/7/2018 2:46:01 AM
Subject: Re[2]: How can I use UUID to generate primary key value via annotation?

I'm not an expert on MySQL, but a quick search reveals MySQL has native UUID support:


So, I again have the same question as before.  Can you use the built-in support to create the primary key?  That's better than creating it in code and passing it in, and eliminates the need for any annotations.

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
Sent: 8/6/2018 11:15:41 PM
Subject: Re: How can I use UUID to generate primary key value via annotation?

Hi, I'm using MySQL. Is there an annotation that I can use to generate UUID automatically for me?


Mailtrack Sender notified by
Mailtrack 08/07/18, 11:14:45 AM

On Tue, Aug 7, 2018 at 11:07 AM Guy Rouillier <[hidden email]> wrote:
You don't mention which DBMS you are using.  PostgreSQL, for example, has built-in UUID support for newer versions.  You can generate the UUID from within the database, so you would not need to supply an annotation to do so.  Is this an acceptable approach?

--
Guy Rouillier

------ Original Message ------
From: "Jun Jason" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/6/2018 2:17:25 AM
Subject: How can I use UUID to generate primary key value via annotation?

Like @GenericGenerator in Hibernate.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.