[hibernate-dev] Could UUID be one of the default strategy when AUTO is requested

Steve Ebersole steve at hibernate.org
Tue Jan 20 10:36:45 EST 2015

On Mon, Jan 19, 2015 at 8:58 AM, Sanne Grinovero <sanne at hibernate.org>

> On 19 January 2015 at 13:33, Emmanuel Bernard <emmanuel at hibernate.org>
> wrote:
> > Hey,
> >
> > I am throwing an idea, let me know what you think.
> > If the return type of the id property of an entity is either String or
> UUID, could we automatically consider one fo the uuid strategy as the one
> matching AUTO?
> +1
> That seems spot-on for the UUID type.
> For String, I wonder if someone would argue that it should actually
> map to a string-encoded output of a sequence.. "1", "2" ...
> I'd personally agree that this is horrible and it should default to
> UUID, just wondering.
> Would this violate any spec?

The javadoc for GenerationType.AUTO does specifically say that "provider
should pick an appropriate strategy for the particular database".  Note the
*for the particular database* portion.  But it does not specifically
disallow UUID-based generation.  So I do not think we violate the spirit of
the spec if we were to do this.

More information about the hibernate-dev mailing list