Skip to main content

UUID

Hibernate ID Generation: IDENTITY vs SEQUENCE vs UUID v7, and Why Batch Inserts Break

Hibernate 7.4.14 primary keys, measured: IDENTITY turns JDBC batching off silently (10,000 inserts became 10,000 single executes), a pooled SEQUENCE needed 400 round trips, and a sequence whose INCREMENT BY disagrees with allocationSize produced negative and duplicate ids. On UUIDs, the common premise is half wrong: Style.TIME is a version-1-flagged id with a constant IP/JVM half, while real RFC 9562 version 7 ships as Style.VERSION_7 from Hibernate 7.0.0. Includes order_inserts, AUTO across six dialects, an H2 index-size comparison (PostgreSQL could not be run), and the Spring Data SELECT-before-INSERT on assigned ids.