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
+26
View File
@@ -0,0 +1,26 @@
# HQL on enum attributes: SQL sent, ORDER BY, and a bad value in the column (PostgreSQL 18)
# Hibernate ORM 7.4.17.Final, H2 2.4.240 and PostgreSQL 18.6, JDK 25
== The SQL Hibernate sends for from X o where o.status = :s (parameter = PAID / PAYMENT_RECEIVED)
-- ORDINAL
sql> select ov1_0.id,ov1_0.status from orders ov1_0 where ov1_0.status=?
-- STRING
sql> select sv1_0.id,sv1_0.status from orders sv1_0 where sv1_0.status=?
-- NAMED_ENUM
sql> select nv1_0.id,nv1_0.status from orders nv1_0 where nv1_0.status=?
-- CONVERTER
sql> select cv1_0.id,cv1_0.status from orders cv1_0 where cv1_0.status=?
-- CONVERTER, enum literal in the HQL text
sql> select cv1_0.id,cv1_0.status from orders cv1_0 where cv1_0.status='P'
== ORDER BY status on NEW, SHIPPED, CANCELLED, PAID stored under each mapping
ORDINAL (enum NEW, PAID, SHIPPED, CANCELLED) : [NEW, PAID, SHIPPED, CANCELLED]
STRING : [CANCELLED, NEW, PAID, SHIPPED]
CONVERTER (codes C, N, P, S, stored values) : [C, N, P, S]
== A value the enum does not know, in the column
insert 'X' with Hibernate's generated check in place : ERROR: new row for relation "orders" violates check constraint "orders_status_check"
read after the check is dropped and 'X' is inserted : jakarta.persistence.PersistenceException <- java.lang.IllegalArgumentException
Unknown CodedV1 code 'X'
ORDINAL with the check dropped and ordinal 7 stored : java.lang.ArrayIndexOutOfBoundsException
Index 7 out of bounds for length 3