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:
@@ -0,0 +1,43 @@
|
||||
# What DDL does each enum mapping produce? (Enum: NEW, PAID, SHIPPED; table orders(id, status))
|
||||
# Hibernate ORM 7.4.17.Final, H2 2.4.240 and PostgreSQL 18.6, JDK 25
|
||||
|
||||
== H2
|
||||
-- no @Enumerated (JPA default)
|
||||
column type: TINYINT
|
||||
check: "STATUS" BETWEEN 0 AND 2
|
||||
-- @Enumerated(ORDINAL)
|
||||
column type: TINYINT
|
||||
check: "STATUS" BETWEEN 0 AND 2
|
||||
-- @Enumerated(STRING)
|
||||
column type: ENUM
|
||||
-- @Enumerated(STRING) + @JdbcTypeCode(NAMED_ENUM)
|
||||
column type: CHARACTER VARYING
|
||||
-- @Convert(AttributeConverter<Enum,String>)
|
||||
column type: CHARACTER VARYING
|
||||
check: "STATUS" IN('P', 'S', 'N')
|
||||
-- @EnumeratedValue + @Enumerated(STRING)
|
||||
column type: CHARACTER VARYING
|
||||
check: "STATUS" IN('P', 'S', 'N')
|
||||
|
||||
== PostgreSQL 18
|
||||
-- no @Enumerated (JPA default)
|
||||
column type: smallint
|
||||
check: CHECK (((status >= 0) AND (status <= 2)))
|
||||
-- @Enumerated(ORDINAL)
|
||||
column type: smallint
|
||||
check: CHECK (((status >= 0) AND (status <= 2)))
|
||||
-- @Enumerated(STRING)
|
||||
column type: character varying(255)
|
||||
check: CHECK (((status)::text = ANY ((ARRAY['NEW'::character varying, 'PAID'::character varying, 'SHIPPED'::character varying])::text[])))
|
||||
-- @Enumerated(STRING) + @JdbcTypeCode(NAMED_ENUM)
|
||||
column type: statusv1
|
||||
enum labels: NEW, PAID, SHIPPED
|
||||
-- @Convert(AttributeConverter<Enum,String>)
|
||||
column type: character varying(255)
|
||||
check: CHECK (((status)::text = ANY ((ARRAY['P'::character varying, 'S'::character varying, 'N'::character varying])::text[])))
|
||||
-- @EnumeratedValue + @Enumerated(STRING)
|
||||
column type: character varying(255)
|
||||
check: CHECK (((status)::text = ANY ((ARRAY['P'::character varying, 'S'::character varying, 'N'::character varying])::text[])))
|
||||
|
||||
== @EnumeratedValue on a String code, without @Enumerated(STRING)
|
||||
org.hibernate.MappingException: @EnumeratedValue for EnumType.ORDINAL must be placed on a field whose type is byte, short, or int: com.ankurm.enums.Variants$EvV1.code
|
||||
Reference in New Issue
Block a user