liveBook · Manning

Enhanced-sequence

As explained in Java Persistence with Spring Data and Hibernate epub

enhanced-sequence is a Hibernate identifier-generation strategy that uses a database sequence when available and otherwise emulates one with a table.

enhanced-sequence is a Hibernate identifier-generation strategy that assigns numeric identifiers before INSERT. It uses a native database sequence when the SQL dialect supports one and otherwise emulates a sequence with an extra table containing one column and row. section 5.2.5

Pre-insert generation makes identifiers available before SQL execution and supports ORM optimizations such as delayed and batched INSERTs. This differs from auto-increment columns, column defaults, and triggers, which provide keys only after INSERT. section 5.2.5

Configure the strategy as shared generator metadata:

  • Set an initial value such as 1000; the first inserted ITEM receives that identifier. section 5.2.4
  • Let Hibernate or Spring Data JPA manage primary-key values rather than assigning them in application code. section 5.2.4

Persisting an item

Create an Item, set its name and auction end, and persist it through Hibernate JPA or save it through Spring Data JPA. The configured generator supplies the primary key; the next value is retained by the native sequence or emulating table. section 5.2.4

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Explains native sequence selection, table fallback, pre-insert timing, and optimizer availability without detailing optimizer algorithms.
Examples
Demonstrates package-level generator metadata and persisting an Item through Hibernate JPA or Spring Data JPA.
What it assumes
Assumes Hibernate or Spring Data JPA usage and basic persistent-entity mapping while teaching the generator configuration itself.
What you can do after
Apply it through Hibernate or Spring Data JPA to obtain framework-managed identifiers before INSERT.
How it connects
Connects identifier generation with database sequences, table emulation, JDBC batching, INSERT timing, Hibernate, and Spring Data JPA.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.