HHH-16694 Generated enum columns should respect the enum's intended order

This commit is contained in:
Christian Beikov 2023-07-24 16:41:14 +02:00
parent 6a4b7467f7
commit 537602b993
1 changed files with 2 additions and 7 deletions

View File

@ -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<? extends Enum<?>> 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<? extends Enum<?>> 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) {