Yes, it would be great to have this in ORM 5.0. Currently, AUTO is a bit AWKWARD to use with MongoDB; if USE_NEW_ID_GENERATOR_MAPPINGS is set to false, we map AUTO to IDENTITY (via Dialect#getNativeIdentifierGeneratorClass()) which only works if the id type is MongoDB's ObjectId type or a String marked with @Type("objectid"). And if USE_NEW_ID_GENERATOR_MAPPINGS is set to true, it will be mapped to the sequence strategy (as per the logic in ORM). This in turn only works if the id is of a numeric type.
So it's quite easy for the user to run into misconfigurations here. I've filed https://hibernate.atlassian.net/browse/HHH-9524 to track this requirement and catch the discussion. Thanks, --Gunnar > 2014-12-01 18:25 GMT+01:00 Steve Ebersole <st...@hibernate.org>: > >> Maybe. I'll have to look a little closer. Is this something you are >> looking at for use with ORM 5.0? >> >> On Fri, Nov 28, 2014 at 5:08 AM, Gunnar Morling <gun...@hibernate.org> >> wrote: >> >>> 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 >>> >>> org.bson.typesObjectId >>> >>> or >>> >>> @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 >>> type. >>> >>> 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? >>> >>> Thanks, >>> >>> --Gunnar >>> _______________________________________________ >>> hibernate-dev mailing list >>> hibernate-dev@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/hibernate-dev >>> >> >> > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev