Given an {{@Entity}} with {{@GenerationType.AUTO}}:
{code}@Id @GeneratedValue(strategy = GenerationType.AUTO) public Integer getId() { return id; }{code}
Hibernate 4.x generated the following SQL: {code:sql}create table MyEntity ( id integer generated by default as identity (start with 1), primary key (id) ) ; {code}
Now, with Hibernate 5.x, this behaviour changend to: {code:sql}create sequence hibernate_sequence start with 1 increment by 1 ; create table MyEntity ( id integer not null, primary key (id) ) ; {code} 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. |
|