Add enums module: enum mapping in Hibernate 7.4.17.Final (ORDINAL trap, STRING, PostgreSQL native enum, AttributeConverter, @EnumeratedValue), what release 2 reads and writes after a constant is inserted, appended or renamed, hbm2ddl=update limits, migrations (H2 2.4.240, PostgreSQL 18.6)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b5y3ArhRbakfu1ELsP
This commit is contained in:
Claude
2026-11-19 23:00:31 +05:30
parent 0db721805b
commit bd0f33a306
22 changed files with 1785 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# PostgreSQL native enum (CREATE TYPE ... AS ENUM): ordering, ALTER TYPE, and what cannot be undone
# Hibernate ORM 7.4.17.Final, H2 2.4.240 and PostgreSQL 18.6, JDK 25
== Ordering. Enum declared as NEW, PAID, SHIPPED, CANCELLED (the order a workflow would use)
-- type created by Hibernate (hbm2ddl = create)
enum labels in sort order: [CANCELLED, NEW, PAID, SHIPPED]
order by status : [CANCELLED, NEW, PAID, SHIPPED]
-- type written by hand, labels in workflow order
order by status : [NEW, PAID, SHIPPED, CANCELLED]
== Release 2 needs CANCELLED, but the database type was created from release 1's NEW, PAID, SHIPPED
write CANCELLED before ALTER TYPE : org.hibernate.exception.DataException <- org.postgresql.util.PSQLException
ERROR: invalid input value for enum statusv1: "CANCELLED"
after ALTER TYPE statusv1 ADD VALUE 'CANCELLED' : OK, rows [1 | PAID, 10 | CANCELLED]
labels now (appended at the end): [NEW, PAID, SHIPPED, CANCELLED]
ADD VALUE 'ON_HOLD' BEFORE 'PAID' : labels [NEW, ON_HOLD, PAID, SHIPPED, CANCELLED]
RENAME VALUE 'PAID' TO 'PAYMENT_RECEIVED' : row 1 is now [PAYMENT_RECEIVED]
ALTER TYPE ... DROP VALUE : ERROR: dropping an enum value is not implemented
== ADD VALUE inside a transaction: usable only after commit
ADD VALUE then INSERT using it in ONE transaction : ERROR: unsafe use of new value "CANCELLED" of enum type statusv1