[hibernate-dev] Making it pluggable how GenerationType.AUTO is mapped

Gunnar Morling gunnar at hibernate.org
Fri Nov 28 06:08:36 EST 2014

Hi Steve, all,

For OGM it would be beneficial if there was an extension point in ORM which
allows us to customize how GenerationType.AUTO is mapped. AFAICS, that's
currently semi-hard coded in ORM. Depending on whether
"new_generator_mappings" is set, either SEQUENCE (true) or "native" (false)
will be used.

Now for the MongoDB grid dialect we'd ideally do the following: If the id
of an entity is declared as



     @Type(type = "objectid") String

then map AUTO to IDENTITY (ObjectId is a MongoDB-specific type which
resembles an identity column). Otherwise map it to TABLE (or SEQUENCE,
which transparently falls back to TABLE).

I.e. this decision would not be a global one, but depend on the specific id

Would this be feasible to do? or is it mandated by JPA somehow that AUTO is
always mapped in the same way? I cannot judge on the amount of changes
required in ORM as atm. AUTO always is mapped in the same way, it doesn't
depend on the specific entity and its id type.

Any thoughts?



More information about the hibernate-dev mailing list