When migrating to Hibernate 6, you need to know the new implicit naming strategy for database sequences. It changes the default sequence Hibernate uses if you don't set a sequence name. Here is what you need to do to switch it back or use your own naming strategy. Set the configuration parameter hibernate.id.db_structure_naming_strategy in your persistence.xml to: - standard (the default in Hibernate 6) - legacy (used in Hibernate >=5.3) - single (used in Hibernate <5.3) - fully qualified class name of your implementation๐ต๐ถ๐ฏ๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ.๐ถ๐ฑ.๐ฑ๐ฏ_๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ_๐ป๐ฎ๐บ๐ถ๐ป๐ด_๐๐๐ฟ๐ฎ๐๐ฒ๐ด๐ = ๐๐๐ฎ๐ป๐ฑ๐ฎ๐ฟ๐ฑ Hibernate 6 uses a separate database sequence for each entity class by default. The name of that sequence consists of the name of the database table to which the entity class gets mapped and the postfix _SEQ. ๐ต๐ถ๐ฏ๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ.๐ถ๐ฑ.๐ฑ๐ฏ_๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ_๐ป๐ฎ๐บ๐ถ๐ป๐ด_๐๐๐ฟ๐ฎ๐๐ฒ๐ด๐ = ๐น๐ฒ๐ด๐ฎ๐ฐ๐ This is the strategy used in versions >=5.3. Hibernate uses hibernate_sequence for primary key attributes annotated with @GeneratedValue that don't reference a generator or the name of the referenced generator ๐ต๐ถ๐ฏ๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ.๐ถ๐ฑ.๐ฑ๐ฏ_๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ_๐ป๐ฎ๐บ๐ถ๐ป๐ด_๐๐๐ฟ๐ฎ๐๐ฒ๐ด๐ = ๐๐ถ๐ป๐ด๐น๐ฒ The naming strategy single is a simpler version of the legacy strategy and gets you the default naming of Hibernate in versions <5.3. It uses the sequence hibernate_sequence if you donโt specify a sequence name. ๐ต๐ถ๐ฏ๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ.๐ถ๐ฑ.๐ฑ๐ฏ_๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ_๐ป๐ฎ๐บ๐ถ๐ป๐ด_๐๐๐ฟ๐ฎ๐๐ฒ๐ด๐ = ๐ฐ๐น๐ฎ๐๐ ๐ป๐ฎ๐บ๐ฒ You can use the same mechanism to provide your own naming strategy. You only need to provide an implementation of the ImplicitDatabaseObjectNamingStrategy interface and configure it in your persistence.xml ๐๐ผ๐ผ๐ธ๐ถ๐ป๐ด ๐ณ๐ผ๐ฟ ๐บ๐ผ๐ฟ๐ฒ ๐ฑ๐ฒ๐๐ฎ๐ถ๐น๐? Check out my post about the new implicit naming strategies for database sequences in Hibernate 6 https://thorben-janssen.com/sequence-naming-strategies-in-hibernate-6 ... ...
Show more