| Given an @Entity with @GenerationType.AUTO:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getId() {
return id;
}
Hibernate 4.x generated the following SQL:
create table MyEntity (
id integer generated by default as identity (start with 1),
primary key (id)
)
Now, with Hibernate 5.x, this behaviour changend to:
create sequence hibernate_sequence start with 1 increment by 1
create table MyEntity (
id integer not null,
primary key (id)
)
This breaks my testcases, since the sequence hibernate_sequence is also being used by all other entities, so I can't rely on certain entities having certain IDs. One might argue that relying on IDs is a bad practice, admittedly. But the point is that the default behaviour just changed. I've checked the JPA Spec for further details about @GenerationType.AUTO, but I didn't find any. |