Offer flag to consider id generator with local scope (legacy non JPA behavior)

Description

The Id generator scope has changed from local scoped (or qualified by entity name, I can't remember) to global scope in strict adherence to the JPA (new TCK test).
http://in.relation.to/2018/02/07/hibernate-orm-5213-final-release/

This is creating migration trouble on large applications. https://twitter.com/aczar0/status/981084503702736896

Consider adding a legacy flag that can be easily set by a user so he can migrate at his/her own pace.

Activity

Show:

Nathan Niesen July 13, 2018 at 9:20 PM

Maybe I'm way off-base in my understanding of this but here are my 2 cents to chew on. This seems to be more of an issue in how Hibernate constructs, configures, references, and implements the generators. The @GeneratedValue name is a reference to a global generator for a persistence unit so referring to it from multiple annotations shouldn't generate duplicate errors. The @SequenceGenerator defines the parameters that should be "passed" to the referenced identifier generator and so also shouldn't generate duplicate errors. The objects needed/created/referenced by the persistence provider to support this should be irrelevant to generating errors/warnings about the configuration. Not looking for response, more or less venting about the "duplicates" being logged as warnings.

Steve Ebersole April 16, 2018 at 2:54 PM

Applied both pull requests (5.3 and 5.2)

Steve Ebersole April 16, 2018 at 2:40 PM

To clarify... we all agree that the JPA requirement is goofy, hence the compliance setting.

Andrea Boriero April 13, 2018 at 11:06 AM
Edited

The proposed solution, see PR is to add a new configuration setting hibernate.jpa.compliance.global_id_generators whose default value is false.

Andrea Boriero April 5, 2018 at 3:54 PM

Both JPA 2.1 and JPA 2.2 specification state for TableGenerator and SequenceGenerator annotations that "The scope of the generator name is global to the persistence unit (across all generator types)"

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created April 3, 2018 at 9:02 AM
Updated July 13, 2018 at 9:20 PM
Resolved April 16, 2018 at 2:54 PM