Skip to content

Commit 30864fe

Browse files
committed
clean up legacy EnumType
1 parent fb9d961 commit 30864fe

File tree

4 files changed

+100
-264
lines changed

4 files changed

+100
-264
lines changed

hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import jakarta.persistence.EnumType;
6565
import jakarta.persistence.TemporalType;
6666

67+
import static java.lang.Boolean.parseBoolean;
6768
import static org.hibernate.mapping.MappingHelper.injectParameters;
6869

6970
/**
@@ -370,9 +371,9 @@ public SelectablePath createSelectablePath(String selectableName) {
370371

371372
protected Resolution<?> buildResolution() {
372373
Properties typeParameters = getTypeParameters();
373-
if ( typeParameters != null
374-
&& Boolean.parseBoolean( typeParameters.getProperty( DynamicParameterizedType.IS_DYNAMIC ) )
375-
&& typeParameters.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
374+
if (typeParameters != null
375+
&& parseBoolean(typeParameters.getProperty(DynamicParameterizedType.IS_DYNAMIC))
376+
&& typeParameters.get(DynamicParameterizedType.PARAMETER_TYPE) == null ) {
376377
createParameterImpl();
377378
}
378379
if ( explicitTypeName != null ) {
@@ -830,10 +831,10 @@ public <T extends UserType<?>> void setExplicitCustomType(Class<T> explicitCusto
830831
}
831832

832833
if ( typeInstance instanceof DynamicParameterizedType ) {
833-
if ( Boolean.parseBoolean( properties.getProperty( DynamicParameterizedType.IS_DYNAMIC ) ) ) {
834-
if ( properties.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
834+
if (parseBoolean(properties.getProperty(DynamicParameterizedType.IS_DYNAMIC))) {
835+
if (properties.get(DynamicParameterizedType.PARAMETER_TYPE) == null) {
835836
final DynamicParameterizedType.ParameterType parameterType = makeParameterImpl();
836-
properties.put( DynamicParameterizedType.PARAMETER_TYPE, parameterType );
837+
properties.put(DynamicParameterizedType.PARAMETER_TYPE, parameterType);
837838
}
838839
}
839840
}

hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.hibernate.internal.CoreLogging;
4646
import org.hibernate.internal.CoreMessageLogger;
4747
import org.hibernate.internal.util.ReflectHelper;
48-
import org.hibernate.internal.util.collections.ArrayHelper;
4948
import org.hibernate.type.descriptor.converter.spi.JpaAttributeConverter;
5049
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
5150
import org.hibernate.service.ServiceRegistry;
@@ -63,6 +62,7 @@
6362

6463
import jakarta.persistence.AttributeConverter;
6564

65+
import static java.lang.Boolean.parseBoolean;
6666
import static org.hibernate.boot.model.convert.spi.ConverterDescriptor.TYPE_NAME_PREFIX;
6767
import static org.hibernate.id.factory.internal.IdentifierGeneratorUtil.createLegacyIdentifierGenerator;
6868
import static org.hibernate.internal.util.collections.ArrayHelper.toBooleanArray;
@@ -930,7 +930,7 @@ protected void createParameterImpl() {
930930
final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
931931
// todo : not sure this works for handling @MapKeyEnumerated
932932
final Annotation[] annotations = xProperty == null
933-
? null
933+
? new Annotation[0]
934934
: xProperty.getAnnotations();
935935

936936
final ClassLoaderService classLoaderService = getMetadata()
@@ -941,13 +941,13 @@ protected void createParameterImpl() {
941941
DynamicParameterizedType.PARAMETER_TYPE,
942942
new ParameterTypeImpl(
943943
classLoaderService.classForTypeName(
944-
typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS )
944+
typeParameters.getProperty(DynamicParameterizedType.RETURNED_CLASS)
945945
),
946946
annotations,
947947
table.getCatalog(),
948948
table.getSchema(),
949949
table.getName(),
950-
Boolean.parseBoolean( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
950+
parseBoolean(typeParameters.getProperty(DynamicParameterizedType.IS_PRIMARY_KEY)),
951951
columnNames,
952952
columnLengths
953953
)
@@ -974,7 +974,7 @@ public DynamicParameterizedType.ParameterType makeParameterImpl() {
974974
final XProperty xProperty = (XProperty) typeParameters.get( DynamicParameterizedType.XPROPERTY );
975975
// todo : not sure this works for handling @MapKeyEnumerated
976976
final Annotation[] annotations = xProperty == null
977-
? null
977+
? new Annotation[0]
978978
: xProperty.getAnnotations();
979979

980980
final ClassLoaderService classLoaderService = getMetadata()
@@ -983,12 +983,12 @@ public DynamicParameterizedType.ParameterType makeParameterImpl() {
983983
.getService( ClassLoaderService.class );
984984

985985
return new ParameterTypeImpl(
986-
classLoaderService.classForTypeName( typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS ) ),
986+
classLoaderService.classForTypeName(typeParameters.getProperty(DynamicParameterizedType.RETURNED_CLASS)),
987987
annotations,
988988
table.getCatalog(),
989989
table.getSchema(),
990990
table.getName(),
991-
Boolean.parseBoolean( typeParameters.getProperty( DynamicParameterizedType.IS_PRIMARY_KEY ) ),
991+
parseBoolean(typeParameters.getProperty(DynamicParameterizedType.IS_PRIMARY_KEY)),
992992
columnNames,
993993
columnLengths
994994
);

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ public void createFromMetadata(
227227
Dialect dialect,
228228
Formatter formatter,
229229
GenerationTarget... targets) {
230-
final SqlStringGenerationContext context = createSqlStringGenerationContext( options, metadata );
231-
final Set<String> exportIdentifiers = setOfSize( 50 );
230+
final SqlStringGenerationContext context = createSqlStringGenerationContext(options, metadata);
231+
final Set<String> exportIdentifiers = setOfSize(50);
232232

233-
createSchemasAndCatalogs( metadata, options, dialect, formatter, context, targets );
234-
// next, create all UDTs
235-
createUserDefinedTypes( metadata, options, dialect, formatter, context, targets );
233+
createSchemasAndCatalogs(metadata, options, dialect, formatter, context, targets);
236234
// next, create all "before table" auxiliary objects
237-
createAuxiliaryObjectsBeforeTables( metadata, options, dialect, formatter, context, exportIdentifiers, targets );
235+
createAuxiliaryObjectsBeforeTables(metadata, options, dialect, formatter, context, exportIdentifiers, targets);
236+
// next, create all UDTs
237+
createUserDefinedTypes(metadata, options, dialect, formatter, context, targets);
238238
// then, create all schema objects (tables, sequences, constraints, etc) in each schema
239239
createSequencesTablesConstraints(
240240
metadata,

0 commit comments

Comments
 (0)