Skip to content

Commit

Permalink
HHH-16694 Generated enum columns should respect the enum's intended o…
Browse files Browse the repository at this point in the history
…rder
  • Loading branch information
beikov committed Aug 2, 2023
1 parent 6a4b746 commit 537602b
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@

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;
Expand Down Expand Up @@ -761,19 +760,15 @@ public String getEnumTypeDeclaration(String name, String[] values) {
}

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) {
return EMPTY_STRING_ARRAY;
}

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) {
Expand Down

0 comments on commit 537602b

Please sign in to comment.