Reputation: 315
The way in which Hibernate determines implicit names for sequences and tables associated with identifier generation has changed in 6.0 which may affect migrating applications.
As of 6.0, Hibernate by default creates a sequence per entity hierarchy instead of a single sequence hibernate_sequence.
Due to this change, users that previously used @GeneratedValue(strategy = GenerationStrategy.AUTO) or simply @GeneratedValue (since AUTO is the default), need to ensure that the database now contains sequences for every entity, named _seq. For an entity Person, a sequence person_seq is expected to exist. It’s best to run hbm2ddl (e.g. by temporarily setting hbm2ddl.auto=create) to obtain a list of DDL statements for the sequences.
As per above statement in the migration guide if i have a entity class as below, please suggest what should i do. Since we have 1000s of tables, having sequence for each table is not possible. I need to make sure this code is backward compatible. Currently my table is having id as identity column. So by changing Generation Type from Auto to identity should be fine? It is working but i am not sure if there are any adverse impact of this or is there a better way.
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
private Long id;
Upvotes: 0
Views: 25