In order to be compliant with the JPA specification, the sequence value stored by Hibernate 5.3 in the database table used by the `javax.persistence.TableGenerator`
is the *last* generated value. Previously, Hibernate stored the *next* sequence value.
For backward compatibility, a new setting called `hibernate.id.generator.stored_last_used` was introduced, which gives you the opportunity to fall back to the old Hibernate behavior.
[NOTE]
====
Existing applications migrating to 5.3 and using the `@TableGenerator` have to set the `hibernate.id.generator.stored_last_used` configuration property to `false`.
====
=== Change in the `@TableGenerator` and `@SequenceGenerator` name scope
In order to be compliant with the JPA specification, generators names are now considered global (e.g. https://hibernate.atlassian.net/browse/HHH-12157[HHH-12157]) .
Configuring two generators, even if with different types but with the same name will now cause a `java.lang.IllegalArgumentException' to be thrown at boot time.
For example, the following mappings are no longer valid:
[source,java]
----
@Entity
@TableGenerator(name = "ID_GENERATOR", ... )
public class FirstEntity {
....
}
@Entity
@TableGenerator(name = "ID_GENERATOR", ... )
public class SecondEntity {
....
}
----
or
[source,java]
----
@Entity
@TableGenerator(name = "ID_GENERATOR", ... )
public class FirstEntity {
....
}
@Entity
@SequenceGenerator(name="ID_GENERATOR", ... )
public class SecondEntity {
....
}
----
The solution is to make all generators unique so that there are no two generators with the same name.