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
