From 537602b9934174f82c2e4c5f4bd0c78bb81cfd88 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 24 Jul 2023 16:41:14 +0200 Subject: [PATCH] HHH-16694 Generated enum columns should respect the enum's intended order --- .../src/main/java/org/hibernate/dialect/Dialect.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 4962146241..5a0e672c67 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -201,7 +201,6 @@ import jakarta.persistence.TemporalType; import static java.lang.Math.ceil; import static java.lang.Math.log; -import static java.util.Arrays.sort; import static org.hibernate.cfg.AvailableSettings.NON_CONTEXTUAL_LOB_CREATION; import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE; import static org.hibernate.cfg.AvailableSettings.USE_GET_GENERATED_KEYS; @@ -761,9 +760,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun } public String getEnumTypeDeclaration(Class> enumType) { - String[] values = getEnumeratedValues( enumType ); - sort( values ); //sort alphabetically, to guarantee alphabetical ordering in queries with 'order by' - return getEnumTypeDeclaration( enumType.getSimpleName(), values ); + return getEnumTypeDeclaration( enumType.getSimpleName(), getEnumeratedValues( enumType ) ); } public String[] getCreateEnumTypeCommand(String name, String[] values) { @@ -771,9 +768,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun } public String[] getCreateEnumTypeCommand(Class> enumType) { - String[] values = getEnumeratedValues( enumType ); - sort( values ); //sort alphabetically, to guarantee alphabetical ordering in queries with 'order by' - return getCreateEnumTypeCommand( enumType.getSimpleName(), values ); + return getCreateEnumTypeCommand( enumType.getSimpleName(), getEnumeratedValues( enumType ) ); } public String[] getDropEnumTypeCommand(String name) {