Skip to content

Commit ab4eb79

Browse files
committed
remove deprecated and very obsolete EnumType
1 parent e577e11 commit ab4eb79

File tree

15 files changed

+370
-74
lines changed

15 files changed

+370
-74
lines changed

hibernate-core/src/main/java/org/hibernate/type/EnumType.java renamed to hibernate-core/src/test/java/org/hibernate/orm/test/EnumType.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-License-Identifier: LGPL-2.1-or-later
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
5-
package org.hibernate.type;
5+
package org.hibernate.orm.test;
66

77
import java.io.Serializable;
88
import java.lang.annotation.Annotation;
@@ -18,8 +18,8 @@
1818
import org.hibernate.annotations.Nationalized;
1919
import org.hibernate.dialect.Dialect;
2020
import org.hibernate.engine.spi.SessionFactoryImplementor;
21-
import org.hibernate.internal.CoreLogging;
2221
import org.hibernate.internal.util.ReflectHelper;
22+
import org.hibernate.type.SqlTypes;
2323
import org.hibernate.type.descriptor.WrapperOptions;
2424
import org.hibernate.type.descriptor.java.EnumJavaType;
2525
import org.hibernate.type.descriptor.java.JavaType;
@@ -31,8 +31,6 @@
3131
import org.hibernate.usertype.EnhancedUserType;
3232
import org.hibernate.usertype.LoggableUserType;
3333

34-
import org.jboss.logging.Logger;
35-
3634
import static jakarta.persistence.EnumType.ORDINAL;
3735
import static jakarta.persistence.EnumType.STRING;
3836
import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean;
@@ -49,7 +47,6 @@
4947
@Deprecated(since="6.2", forRemoval=true)
5048
public class EnumType<T extends Enum<T>>
5149
implements EnhancedUserType<T>, DynamicParameterizedType, LoggableUserType, TypeConfigurationAware, Serializable {
52-
private static final Logger LOG = CoreLogging.logger( EnumType.class );
5350

5451
public static final String ENUM = "enumClass";
5552
public static final String NAMED = "useNamed";
@@ -156,14 +153,6 @@ else if ( reader != null ) {
156153
jdbcType = descriptor.getRecommendedJdbcType( indicators );
157154
isOrdinal = indicators.getEnumeratedType() != STRING;
158155
}
159-
160-
if ( LOG.isDebugEnabled() ) {
161-
LOG.debugf(
162-
"Using %s-based conversion for Enum %s",
163-
isOrdinal() ? "ORDINAL" : "NAMED",
164-
enumClass.getName()
165-
);
166-
}
167156
}
168157

169158
private jakarta.persistence.EnumType getEnumType(ParameterType reader) {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import java.sql.SQLException;
1010
import java.sql.Types;
1111

12+
import org.hibernate.orm.test.EnumType;
1213
import org.hibernate.orm.test.annotations.enumerated.enums.FirstLetter;
1314
import org.hibernate.type.descriptor.WrapperOptions;
1415

1516
/**
1617
* @author Janario Oliveira
1718
*/
18-
public class FirstLetterType extends org.hibernate.type.EnumType<FirstLetter> {
19+
public class FirstLetterType extends EnumType<FirstLetter> {
1920

2021
@Override
2122
public int getSqlType() {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import java.sql.SQLException;
1010
import java.sql.Types;
1111

12+
import org.hibernate.orm.test.EnumType;
1213
import org.hibernate.orm.test.annotations.enumerated.enums.LastNumber;
1314
import org.hibernate.type.descriptor.WrapperOptions;
1415

1516
/**
1617
* @author Janario Oliveira
1718
*/
18-
public class LastNumberType extends org.hibernate.type.EnumType<LastNumber> {
19+
public class LastNumberType extends EnumType<LastNumber> {
1920

2021
@Override
2122
public int getSqlType() {

hibernate-core/src/test/java/org/hibernate/orm/test/cdi/lifecycle/ExtendedBeanManagerNotAvailableDuringTypeResolutionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static class TheEntity {
6464
" </id>\n" +
6565
" <property name=\"name\" />\n" +
6666
" <property name=\"myEnum\" >\n" +
67-
" <type name=\"org.hibernate.type.EnumType\">\n" +
67+
" <type name=\"org.hibernate.orm.test.EnumType\">\n" +
6868
" <param name=\"enumClass\">" + MyEnum.class.getName() + "</param>\n" +
6969
" </type>\n" +
7070
" </property>\n" +

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/typedef/NamedEnumUserType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import java.util.Properties;
88

9-
import org.hibernate.type.EnumType;
9+
import org.hibernate.orm.test.EnumType;
1010

1111
/**
1212
* A simple user type where we force enums to be saved by name, not ordinal

hibernate-core/src/test/resources/org/hibernate/orm/test/mapping/converted/enums/Person.hbm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
</id>
1717

1818
<property name="gender" not-null="true">
19-
<type name="org.hibernate.type.EnumType">
19+
<type name="org.hibernate.orm.test.EnumType">
2020
<param name="enumClass">org.hibernate.orm.test.mapping.converted.enums.Gender</param>
2121
<param name="type">12</param>
2222
</type>
2323
</property>
2424

2525
<property name="hairColor" not-null="true">
26-
<type name="org.hibernate.type.EnumType">
26+
<type name="org.hibernate.orm.test.EnumType">
2727
<param name="enumClass">org.hibernate.orm.test.mapping.converted.enums.HairColor</param>
2828
</type>
2929
</property>
3030

3131
<property name="originalHairColor">
32-
<type name="org.hibernate.type.EnumType">
32+
<type name="org.hibernate.orm.test.EnumType">
3333
<param name="enumClass">org.hibernate.orm.test.mapping.converted.enums.HairColor</param>
3434
<param name="type">12</param>
3535
</type>

hibernate-core/src/test/resources/org/hibernate/orm/test/mapping/converted/enums/mappings.hbm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<generator class="increment" />
1313
</id>
1414
<property name="enum1">
15-
<type name="org.hibernate.type.EnumType">
15+
<type name="org.hibernate.orm.test.EnumType">
1616
<!--<param name="useNamed">true</param>-->
1717
<param name="enumClass">org.hibernate.orm.test.mapping.converted.enums.UnspecifiedEnumTypeEntity$E1</param>
1818
</type>
1919
</property>
2020
<property name="enum2">
21-
<type name="org.hibernate.type.EnumType">
21+
<type name="org.hibernate.orm.test.EnumType">
2222
<!--<param name="useNamed">false</param>-->
2323
<param name="enumClass">org.hibernate.orm.test.mapping.converted.enums.UnspecifiedEnumTypeEntity$E2</param>
2424
</type>

hibernate-core/src/test/resources/org/hibernate/orm/test/quote/DataPoint.hbm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
1212

1313
<hibernate-mapping package="org.hibernate.orm.test.quote">
14-
<typedef name="enumType" class="org.hibernate.type.EnumType">
14+
<typedef name="enumType" class="org.hibernate.orm.test.EnumType">
1515
<param name="enumClass">org.hibernate.orm.test.quote.DataPoint$DataPointEnum</param>
1616
</typedef>
1717

hibernate-core/src/test/resources/org/hibernate/query/hhh12076/Settlement.hbm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</property>
3737
<property name="status">
3838
<column name="status" not-null="true"/>
39-
<type name="org.hibernate.type.EnumType">
39+
<type name="org.hibernate.orm.test.EnumType">
4040
<param name="type">12</param>
4141
<param name="enumClass">org.hibernate.orm.test.query.hhh12076.SettlementStatus</param>
4242
</type>

hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/BasicMetadataGenerator.java

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.hibernate.mapping.SimpleValue;
1515
import org.hibernate.mapping.Value;
1616
import org.hibernate.type.BasicType;
17-
import org.hibernate.type.CustomType;
18-
import org.hibernate.type.EnumType;
1917
import org.hibernate.type.Type;
2018

2119
/**
@@ -58,21 +56,6 @@ public boolean addBasic(
5856
return false;
5957
}
6058

61-
private void mapEnumerationType(TypeSpecification typeDefinition, EnumType type, Properties parameters) {
62-
if ( parameters.getProperty( EnumType.ENUM ) != null ) {
63-
typeDefinition.setParameter( EnumType.ENUM, parameters.getProperty( EnumType.ENUM ) );
64-
}
65-
else {
66-
typeDefinition.setParameter( EnumType.ENUM, type.getEnumClass().getName() );
67-
}
68-
if ( parameters.getProperty( EnumType.NAMED ) != null ) {
69-
typeDefinition.setParameter( EnumType.NAMED, parameters.getProperty( EnumType.NAMED ) );
70-
}
71-
else {
72-
typeDefinition.setParameter( EnumType.NAMED, Boolean.toString( !type.isOrdinal() ) );
73-
}
74-
}
75-
7659
private boolean isAddNestedType(Value value) {
7760
if ( value instanceof SimpleValue simpleValue ) {
7861
return simpleValue.getTypeParameters() != null;
@@ -99,19 +82,12 @@ private void applyNestedType(SimpleValue value, BasicAttribute attribute) {
9982
final TypeSpecification typeSpecification = new TypeSpecification( typeName );
10083
attribute.setType( typeSpecification );
10184

102-
Type type = value.getType();
103-
if ( type instanceof CustomType && ((CustomType<?>) type).getUserType() instanceof EnumType ) {
104-
// Proper handling of nasty legacy EnumType
105-
mapEnumerationType( typeSpecification, (EnumType) ((CustomType<?>) type).getUserType(), typeParameters );
106-
}
107-
else {
108-
// By default, copying all Hibernate properties
109-
for ( Object object : typeParameters.keySet() ) {
110-
final String keyType = (String) object;
111-
final String property = typeParameters.getProperty( keyType );
112-
if ( property != null ) {
113-
typeSpecification.setParameter( keyType, property );
114-
}
85+
// By default, copying all Hibernate properties
86+
for ( Object object : typeParameters.keySet() ) {
87+
final String keyType = (String) object;
88+
final String property = typeParameters.getProperty( keyType );
89+
if ( property != null ) {
90+
typeSpecification.setParameter( keyType, property );
11591
}
11692
}
11793
}

0 commit comments

Comments
 (0)