Is Hibernate Identity Generator single?

How does Hibernate deal with identity generators? The generator class looks like a singleton synchronized generation method with no static fields. Is it a generator instance for each session, is it a single single JVM module, or is it handled in a completely different way?

+3


source to share


1 answer


Hibernate has many ID generators and IDENTITY SEQUENCE and TABLE use the database to generate a new ID value. Synchronization takes place in the database using locks (soft-locks for IDENTITY and SEQUENCE and hard locks for TABLE).



Generators are stored in SessionFactory

, so they are shared by everyone Sessions

.

+1


source







All Articles