Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5y3ArhRbakfu1ELsP
27 lines
1.6 KiB
Plaintext
27 lines
1.6 KiB
Plaintext
# 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
|