[hibernate-dev] Database with UUID support

David Driscoll driscoll.davidj at gmail.com
Thu May 27 21:54:13 EDT 2010


In regards to : postgresql - is it reasonable to require this uuid-ossp
module?
In my experience, I avoided using the uuid-ossp module and just used
java.util.UUID.randomUUID() in my
model class to generate my uuid for me instead having the database generate
the uuid.
Depending on how much access rights you have to your database, you might be
able
to easily install uuid-ossp. On the other hand even if you have rights to
install it,
you may wish to avoid taking any maintenance down time which may be
required.

Regards,

Dave


On Thu, May 27, 2010 at 8:01 AM, <hibernate-dev-request at lists.jboss.org>wrote:

> Send hibernate-dev mailing list submissions to
>        hibernate-dev at lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://lists.jboss.org/mailman/listinfo/hibernate-dev
> or, via email, send a message with subject or body 'help' to
>        hibernate-dev-request at lists.jboss.org
>
> You can reach the person managing the list at
>        hibernate-dev-owner at lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of hibernate-dev digest..."
>
>
> Today's Topics:
>
>   1. Optimizing reflection optimization (?????? ????????)
>   2. Database with UUID support (Steve Ebersole)
>   3. Re: Optimizing reflection optimization (Emmanuel Bernard)
>   4. Re: Database with UUID support (Cody Lerum)
>   5. Re: Database with UUID support (Steve Ebersole)
>   6. Re: Database with UUID support (Emmanuel Bernard)
>   7. Re: Database with UUID support (Steve Ebersole)
>   8. Re: Database with UUID support (Steve Ebersole)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 26 May 2010 19:29:01 +0300
> From: ?????? ???????? <kirill.klenski at gmail.com>
> Subject: [hibernate-dev] Optimizing reflection optimization
> To: hibernate-dev at lists.jboss.org
> Message-ID:
>        <AANLkTimK4Aorz1EfWODJPwNo0f7HYGFO9DgWK3YvNZPb at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi,
>
> Recently my task involved enabling hibernate reflection optimization in our
> application.
>
> Versions used:
> hibernate-core-3.3.1.GA
> javassist-3.4.GA
>
> Below are some thoughts that hopefully could help to improve the product.
>
> 1. I have noticed that
> org.hibernate.bytecode.javassist.BulkAccessorFactory.findAccessors(...) is
> searching for accessor methods in the optimized entity class only. This
> means that the methods from the superclasses are not visible during
> BulkAccessor creation unless overridden by child classes. By enhancing the
> algorithm to search down the inheritance tree we could avoid creation of
> redundant methods which increase the code verbosity a lot. In our case
> almost all the entities are inherited from the base classes having the
> common entity properties defined, so the reflection optimization does not
> work for any of them until we override the inherited methods in all the
> child classes. The implementation is trivial, but I have got a ready
> prototype if anybody is interested.
>
> 2. It seems that it should be also possible to optimize the
> EntityTuplizer's
> getPropertyValue and setPropertyValue calls in the similar way how the
> getPropertyValues and setPropertyValues are currently optimized.
>
> Best regards,
> Kirill Klenski
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 26 May 2010 15:24:46 -0500
> From: Steve Ebersole <steve at hibernate.org>
> Subject: [hibernate-dev] Database with UUID support
> To: "hibernate-dev at lists.jboss.org" <hibernate-dev at lists.jboss.org>
> Message-ID: <1274905486.21430.72.camel at apollo>
> Content-Type: text/plain; charset="UTF-8"
>
> In regards to
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3579 I am
> trying to put together the best all around support for java.util.UUID we
> can as a type.
>
> Obviously most databases "support uuid" via char/varchar data type.
> Postgresql being the lone exception of which I am aware with their
> special UUID datatype, even though they choose to map it to
> java.sql.Types.OTHER (don't get me started).  So for sure we can support
> UUID in every database.
>
> The next logical thought was supporting UUID as an identifier value.  If
> we were to add that what I would really prefer is a way to obtain the
> UUID ahead of time (pre-insert) which would mean knowing what databases
> supported a UUID-generation function and, for those that did, what that
> function is.  For those that do not, is using
> java.util.UUID.randomUUID() a viable alternative?
>
> A list of major databases and their support/non-support for generating
> UUID values that I know of are as follows:
>
> 1) postgresql - database itself does not support generation, instead
> relying on an optional module called uuid-ossp
> 2) mysql - supports generation via the UUID() function
> 3) h2 - supports generation via the RANDOM_UUID()
> 4) hsqldb - does not support generation afaict
> 5) derby - does not support generation afaict
> 6) db2 - does have a GENERATE_UNIQUE() function; was not able to tell if
> that is compatible with java.util.UUID
> 7) firebird - supports generation via GEN_UUID()
> 8) informix - does not support generation afaict
> 9) ingres - supports via UUID_CREATE()
> 10) oracle - supports via SYS_GUID()
> 11) maxdb (sapdb) - does not support generation afaict
> 12) mssql (sql server) - does have a NEWID() function, though it
> generates a string with hyphons in it; not sure how/if this value
> relates to java.util.UUID
> 13) sybase - like mssql also has a NEWID() function which here can
> additionally be given a parameter to say whether to include hyphons etc;
> again, not sure how/if this value relates to java.util.UUID
> 14) terradata - does not support generation afaict
>
> DISCLAIMER : When I say "does not support" I mean in the base server
> install.  As I pointed out with postgresql I understand some might have
> additional optional or third-party modules that add such capabilities
>
>
> So by my count, that means that we can have pretty complete support for
> UUID on the following databases without any extra requirements:
> a) mysql
> b) h2
> c) firebird
> d) ingres
> e) oracle
>
> Databases with potential support:
> a) postgresql - is it reasonable to require this uuid-ossp module?
> b) db2 - what is the compatibility of its GENERATE_UNIQUE() function
> with java.util.UUID?
> c) mssql/sybase - what is the compatibility of NEWID() function with
> with java.util.UUID?
>
> For databases which do not support UUID generation, the question becomes
> how do we support that in hibernate for identifiers?  Do we rely on
> java.util.UUID.randomUUID()?  Do you use a special generator like
> http://jug.safehaus.org/ ?  Other options?
>
> Also, if anyone notices issues in my db support investigations please
> let me know.
>
> --
> Steve Ebersole <steve at hibernate.org>
> http://hibernate.org
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 26 May 2010 22:53:32 +0200
> From: Emmanuel Bernard <emmanuel at hibernate.org>
> Subject: Re: [hibernate-dev] Optimizing reflection optimization
> To: ?????? ????????     <kirill.klenski at gmail.com>
> Cc: hibernate-dev at lists.jboss.org
> Message-ID: <C953A377-1572-4A88-8D16-B24ED07B387E at hibernate.org>
> Content-Type: text/plain; charset=utf-8
>
> Hi,
> Have you noticed a perf difference in your application with and without the
> patch?
> I am wondering if modern VMs have catched up with what Javassist does.
>
> On 26 mai 2010, at 18:29, ?????? ???????? wrote:
>
> > 1. I have noticed that
> > org.hibernate.bytecode.javassist.BulkAccessorFactory.findAccessors(...)
> is
> > searching for accessor methods in the optimized entity class only. This
> > means that the methods from the superclasses are not visible during
> > BulkAccessor creation unless overridden by child classes. By enhancing
> the
> > algorithm to search down the inheritance tree we could avoid creation of
> > redundant methods which increase the code verbosity a lot. In our case
> > almost all the entities are inherited from the base classes having the
> > common entity properties defined, so the reflection optimization does not
> > work for any of them until we override the inherited methods in all the
> > child classes. The implementation is trivial, but I have got a ready
> > prototype if anybody is interested.
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 26 May 2010 15:30:00 -0600
> From: Cody Lerum <cody.lerum at gmail.com>
> Subject: Re: [hibernate-dev] Database with UUID support
> To: Steve Ebersole <steve at hibernate.org>
> Cc: "hibernate-dev at lists.jboss.org" <hibernate-dev at lists.jboss.org>
> Message-ID:
>        <AANLkTikQJ294O2IKpWye4lWYh9DvC6rpCujvyIk7cHnv at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I prefer time based (version 1) UUID due the insert performance of random
> ID's.
>
> Though that sends you down the road of using a third party generator.
> FWIW http://johannburkard.de/software/uuid/ is recommended on the
> Apache Cassandra wiki.
>
> On Wed, May 26, 2010 at 2:24 PM, Steve Ebersole <steve at hibernate.org>
> wrote:
> > In regards to
> > http://opensource.atlassian.com/projects/hibernate/browse/HHH-3579 I am
> > trying to put together the best all around support for java.util.UUID we
> > can as a type.
> >
> > Obviously most databases "support uuid" via char/varchar data type.
> > Postgresql being the lone exception of which I am aware with their
> > special UUID datatype, even though they choose to map it to
> > java.sql.Types.OTHER (don't get me started). ?So for sure we can support
> > UUID in every database.
> >
> > The next logical thought was supporting UUID as an identifier value. ?If
> > we were to add that what I would really prefer is a way to obtain the
> > UUID ahead of time (pre-insert) which would mean knowing what databases
> > supported a UUID-generation function and, for those that did, what that
> > function is. ?For those that do not, is using
> > java.util.UUID.randomUUID() a viable alternative?
> >
> > A list of major databases and their support/non-support for generating
> > UUID values that I know of are as follows:
> >
> > 1) postgresql - database itself does not support generation, instead
> > relying on an optional module called uuid-ossp
> > 2) mysql - supports generation via the UUID() function
> > 3) h2 - supports generation via the RANDOM_UUID()
> > 4) hsqldb - does not support generation afaict
> > 5) derby - does not support generation afaict
> > 6) db2 - does have a GENERATE_UNIQUE() function; was not able to tell if
> > that is compatible with java.util.UUID
> > 7) firebird - supports generation via GEN_UUID()
> > 8) informix - does not support generation afaict
> > 9) ingres - supports via UUID_CREATE()
> > 10) oracle - supports via SYS_GUID()
> > 11) maxdb (sapdb) - does not support generation afaict
> > 12) mssql (sql server) - does have a NEWID() function, though it
> > generates a string with hyphons in it; not sure how/if this value
> > relates to java.util.UUID
> > 13) sybase - like mssql also has a NEWID() function which here can
> > additionally be given a parameter to say whether to include hyphons etc;
> > again, not sure how/if this value relates to java.util.UUID
> > 14) terradata - does not support generation afaict
> >
> > DISCLAIMER : When I say "does not support" I mean in the base server
> > install. ?As I pointed out with postgresql I understand some might have
> > additional optional or third-party modules that add such capabilities
> >
> >
> > So by my count, that means that we can have pretty complete support for
> > UUID on the following databases without any extra requirements:
> > a) mysql
> > b) h2
> > c) firebird
> > d) ingres
> > e) oracle
> >
> > Databases with potential support:
> > a) postgresql - is it reasonable to require this uuid-ossp module?
> > b) db2 - what is the compatibility of its GENERATE_UNIQUE() function
> > with java.util.UUID?
> > c) mssql/sybase - what is the compatibility of NEWID() function with
> > with java.util.UUID?
> >
> > For databases which do not support UUID generation, the question becomes
> > how do we support that in hibernate for identifiers? ?Do we rely on
> > java.util.UUID.randomUUID()? ?Do you use a special generator like
> > http://jug.safehaus.org/ ? ?Other options?
> >
> > Also, if anyone notices issues in my db support investigations please
> > let me know.
> >
> > --
> > Steve Ebersole <steve at hibernate.org>
> > http://hibernate.org
> >
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >
>
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 26 May 2010 20:13:48 -0500
> From: Steve Ebersole <steve at hibernate.org>
> Subject: Re: [hibernate-dev] Database with UUID support
> To: Cody Lerum <cody.lerum at gmail.com>
> Cc: "hibernate-dev at lists.jboss.org" <hibernate-dev at lists.jboss.org>
> Message-ID: <1274922828.21430.94.camel at apollo>
> Content-Type: text/plain; charset="UTF-8"
>
> The main drawback there imo is that it uses its own UUID implementation
> (com.eaio.uuid.UUID) rather than simply generating java.util.UUID.  To
> do so you have "bridge" as pointed out in the Cassandra FAQ:
> http://wiki.apache.org/cassandra/FAQ#working_with_timeuuid_in_java
>
> Not to mention the maven information he lists is inaccurate (there is no
> repo at http://eaio.com/maven2) and the latest posts on that website are
> from 2007.
>
> On Wed, 2010-05-26 at 15:30 -0600, Cody Lerum wrote:
> > I prefer time based (version 1) UUID due the insert performance of random
> ID's.
> >
> > Though that sends you down the road of using a third party generator.
> > FWIW http://johannburkard.de/software/uuid/ is recommended on the
> > Apache Cassandra wiki.
> >
> > On Wed, May 26, 2010 at 2:24 PM, Steve Ebersole <steve at hibernate.org>
> wrote:
> > > In regards to
> > > http://opensource.atlassian.com/projects/hibernate/browse/HHH-3579 I
> am
> > > trying to put together the best all around support for java.util.UUID
> we
> > > can as a type.
> > >
> > > Obviously most databases "support uuid" via char/varchar data type.
> > > Postgresql being the lone exception of which I am aware with their
> > > special UUID datatype, even though they choose to map it to
> > > java.sql.Types.OTHER (don't get me started).  So for sure we can
> support
> > > UUID in every database.
> > >
> > > The next logical thought was supporting UUID as an identifier value.
>  If
> > > we were to add that what I would really prefer is a way to obtain the
> > > UUID ahead of time (pre-insert) which would mean knowing what databases
> > > supported a UUID-generation function and, for those that did, what that
> > > function is.  For those that do not, is using
> > > java.util.UUID.randomUUID() a viable alternative?
> > >
> > > A list of major databases and their support/non-support for generating
> > > UUID values that I know of are as follows:
> > >
> > > 1) postgresql - database itself does not support generation, instead
> > > relying on an optional module called uuid-ossp
> > > 2) mysql - supports generation via the UUID() function
> > > 3) h2 - supports generation via the RANDOM_UUID()
> > > 4) hsqldb - does not support generation afaict
> > > 5) derby - does not support generation afaict
> > > 6) db2 - does have a GENERATE_UNIQUE() function; was not able to tell
> if
> > > that is compatible with java.util.UUID
> > > 7) firebird - supports generation via GEN_UUID()
> > > 8) informix - does not support generation afaict
> > > 9) ingres - supports via UUID_CREATE()
> > > 10) oracle - supports via SYS_GUID()
> > > 11) maxdb (sapdb) - does not support generation afaict
> > > 12) mssql (sql server) - does have a NEWID() function, though it
> > > generates a string with hyphons in it; not sure how/if this value
> > > relates to java.util.UUID
> > > 13) sybase - like mssql also has a NEWID() function which here can
> > > additionally be given a parameter to say whether to include hyphons
> etc;
> > > again, not sure how/if this value relates to java.util.UUID
> > > 14) terradata - does not support generation afaict
> > >
> > > DISCLAIMER : When I say "does not support" I mean in the base server
> > > install.  As I pointed out with postgresql I understand some might have
> > > additional optional or third-party modules that add such capabilities
> > >
> > >
> > > So by my count, that means that we can have pretty complete support for
> > > UUID on the following databases without any extra requirements:
> > > a) mysql
> > > b) h2
> > > c) firebird
> > > d) ingres
> > > e) oracle
> > >
> > > Databases with potential support:
> > > a) postgresql - is it reasonable to require this uuid-ossp module?
> > > b) db2 - what is the compatibility of its GENERATE_UNIQUE() function
> > > with java.util.UUID?
> > > c) mssql/sybase - what is the compatibility of NEWID() function with
> > > with java.util.UUID?
> > >
> > > For databases which do not support UUID generation, the question
> becomes
> > > how do we support that in hibernate for identifiers?  Do we rely on
> > > java.util.UUID.randomUUID()?  Do you use a special generator like
> > > http://jug.safehaus.org/ ?  Other options?
> > >
> > > Also, if anyone notices issues in my db support investigations please
> > > let me know.
> > >
> > > --
> > > Steve Ebersole <steve at hibernate.org>
> > > http://hibernate.org
> > >
> > > _______________________________________________
> > > hibernate-dev mailing list
> > > hibernate-dev at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> > >
>
>
> --
> Steve Ebersole <steve at hibernate.org>
> http://hibernate.org
>
>
>
> ------------------------------
>
> Message: 6
> Date: Thu, 27 May 2010 08:27:47 +0200
> From: Emmanuel Bernard <emmanuel at hibernate.org>
> Subject: Re: [hibernate-dev] Database with UUID support
> To: hibernate-dev at lists.jboss.org
> Message-ID: <4E2E28D3-0EBD-4826-AFCC-F5E562730654 at hibernate.org>
> Content-Type: text/plain; charset=us-ascii
>
> To his credit a UUID impl is not a 10 year project plan ;) I would not
> necessarily consider it abandonware rather than done.
>
> On 27 mai 2010, at 03:13, Steve Ebersole wrote:
>
> > and the latest posts on that website are
> > from 2007.
>
>
>
>
> ------------------------------
>
> Message: 7
> Date: Thu, 27 May 2010 06:12:40 -0500
> From: "Steve Ebersole" <steve at hibernate.org>
> Subject: Re: [hibernate-dev] Database with UUID support
> To: "Emmanuel Bernard" <emmanuel at hibernate.org>,
>        "hibernate-dev at lists.jboss.org" <hibernate-dev at lists.jboss.org>
> Message-ID: <4bfe53af.8c43e70a.68d9.2a1d at mx.google.com>
> Content-Type: text/plain; charset=UTF-8
>
> The site is not just about the UUID generator project. &nbsp;He wrote posts
> on ohter subjects as well.
>
> My point there is more to the maven repo. &nbsp;How do we reference this?
> &nbsp;Are we ending up hosting another artifact? &nbsp;How do we even
> contact him to find out?
>
>
>
>
>
> -- Sent from my Palm Pre
> steve at hibernate.org
> http://hibernate.orgOn May 27, 2010 1:28 AM, Emmanuel Bernard &
> lt;emmanuel at hibernate.org <lt%3Bemmanuel at hibernate.org>&gt; wrote:
>
> To his credit a UUID impl is not a 10 year project plan ;) I would not
> necessarily consider it abandonware rather than done.
>
>
>
> On 27 mai 2010, at 03:13, Steve Ebersole wrote:
>
>
>
> &gt; and the latest posts on that website are
>
> &gt; from 2007.
>
>
>
>
>
> _______________________________________________
>
> hibernate-dev mailing list
>
> hibernate-dev at lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Thu, 27 May 2010 07:01:49 -0500
> From: Steve Ebersole <steve at hibernate.org>
> Subject: Re: [hibernate-dev] Database with UUID support
> To: Emmanuel Bernard <emmanuel at hibernate.org>
> Cc: "hibernate-dev at lists.jboss.org" <hibernate-dev at lists.jboss.org>
> Message-ID: <1274961709.21430.116.camel at apollo>
> Content-Type: text/plain; charset="UTF-8"
>
> Anyway, the discussion here wrt this UUID project is all about
> generating the UUID value in Java.  The first point is to determine
> whether there is any benefit to relying on the database to generate
> these for us in the cases when they can.
>
> Secondly there is the question of if we are going to do it in Java then
> what is the correct approach.  Both libraries mentioned here (UUID and
> JUG) use MAC address resolution in building the uuid value.  JUG is
> updating to use java.util.UUID, but relies on native code for
> mac-address-resoltion; UUID use its own UUID class but does not need
> native code for the mac-address-resolution (it uses OS-sniffing and
> system calls).  Heck maybe we offer this as a strategy configurable with
> the Configuration/SessionFactory.
>
> interface UUIDGenerationStrategy extends Serializable {
>    public int getGenerationVersion(); // informational
>    public UUID generateUUID(SessionImplementor session);
> }
>
> But first things first...
>
> Do we use database uuid generation if supported?  Is that itself perhaps
> just a strategy?
>
>
> On Thu, 2010-05-27 at 06:12 -0500, Steve Ebersole wrote:
> > The site is not just about the UUID generator project.  He wrote posts
> > on ohter subjects as well.
> >
> > My point there is more to the maven repo.  How do we reference this?
> >  Are we ending up hosting another artifact?  How do we even contact
> > him to find out?
> >
> >
> >
> >
> >
> > -- Sent from my Palm Pre
> >
> > steve at hibernate.org
> > http://hibernate.org
> > ______________________________________________________________________
> > On May 27, 2010 1:28 AM, Emmanuel Bernard <emmanuel at hibernate.org>
> > wrote:
> >
> > To his credit a UUID impl is not a 10 year project plan ;) I would not
> > necessarily consider it abandonware rather than done.
> >
> > On 27 mai 2010, at 03:13, Steve Ebersole wrote:
> >
> > > and the latest posts on that website are
> > > from 2007.
> >
> >
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
> --
> Steve Ebersole <steve at hibernate.org>
> http://hibernate.org
>
>
>
> ------------------------------
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
> End of hibernate-dev Digest, Vol 47, Issue 18
> *********************************************
>



-- 
David J. Driscoll

www.EnduroTracker.com
EnduroTracker.BlogSpot.com
www.google.com/profiles/Driscoll.DavidJ



More information about the hibernate-dev mailing list