Saturday, January 12, 2019

Hibernate IDENTITY vs SEQUENCE entity identifier generators?

  • The IDENTITY generator will always require a database hit for fetching the primary key value without waiting for the flush to synchronize the current entity state transitions with the database.
  •  IDENTITY generator doesn't play well with Hibernate write-behind first level cache strategy.
  • Insert a row without specifying a value for the ID. After inserting the row, ask the database for the last generated ID.
  • The GenerationType.IDENTITY is the easiest to use but not the best one from a performance point of view.

No comments:

Post a Comment

Spring Annotations