Skip to content

Commit 515dcbe

Browse files
committed
HHH-18998 remove added code which is probably not necessary
(need to check with @sebersole)
1 parent 322b67f commit 515dcbe

File tree

4 files changed

+10
-60
lines changed

4 files changed

+10
-60
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
package org.hibernate.boot.model;
66

77
import java.io.Serializable;
8-
import java.lang.annotation.Annotation;
9-
import java.lang.reflect.Constructor;
10-
import java.lang.reflect.InvocationTargetException;
118
import java.sql.Types;
129
import java.util.Arrays;
1310
import java.util.Collections;
@@ -42,6 +39,7 @@
4239
import org.hibernate.type.spi.TypeConfigurationAware;
4340
import org.hibernate.usertype.UserType;
4441

42+
import static java.util.Collections.emptyMap;
4543
import static org.hibernate.boot.model.process.internal.InferredBasicValueResolver.resolveSqlTypeIndicators;
4644
import static org.hibernate.mapping.MappingHelper.injectParameters;
4745

@@ -101,35 +99,32 @@ public Map<String,String> getParameters() {
10199

102100
public BasicValue.Resolution<?> resolve(
103101
Map<?,?> localConfigParameters,
104-
Annotation typeAnnotation,
105102
MutabilityPlan<?> explicitMutabilityPlan,
106103
MetadataBuildingContext context,
107104
JdbcTypeIndicators indicators) {
108105
if ( CollectionHelper.isEmpty( localConfigParameters ) ) {
109106
// we can use the re-usable resolution...
110107
if ( reusableResolution == null ) {
111-
reusableResolution = createResolution( name, Collections.emptyMap(), typeAnnotation, indicators, context );
108+
reusableResolution = createResolution( name, emptyMap(), indicators, context );
112109
}
113110
return reusableResolution;
114111
}
115112
else {
116113
final String name = this.name + ":" + NAME_COUNTER.getAndIncrement();
117-
return createResolution( name, localConfigParameters, typeAnnotation, indicators, context );
114+
return createResolution( name, localConfigParameters, indicators, context );
118115
}
119116
}
120117

121118
private BasicValue.Resolution<?> createResolution(
122119
String name,
123120
Map<?,?> usageSiteProperties,
124-
Annotation typeAnnotation,
125121
JdbcTypeIndicators indicators,
126122
MetadataBuildingContext context) {
127123
return createResolution(
128124
name,
129125
typeImplementorClass,
130126
parameters,
131127
usageSiteProperties,
132-
typeAnnotation,
133128
indicators,
134129
context
135130
);
@@ -140,7 +135,6 @@ private static <T> BasicValue.Resolution<T> createResolution(
140135
Class<T> typeImplementorClass,
141136
Map<?,?> parameters,
142137
Map<?,?> usageSiteProperties,
143-
Annotation typeAnnotation,
144138
JdbcTypeIndicators indicators,
145139
MetadataBuildingContext context) {
146140
final BootstrapContext bootstrapContext = context.getBootstrapContext();
@@ -154,7 +148,8 @@ private static <T> BasicValue.Resolution<T> createResolution(
154148
if ( isKnownType ) {
155149

156150
final T typeInstance =
157-
instantiateType( name, typeImplementorClass, typeAnnotation, context, bootstrapContext );
151+
instantiateType( bootstrapContext.getServiceRegistry(), context.getBuildingOptions(),
152+
name, typeImplementorClass, bootstrapContext.getCustomTypeProducer() );
158153

159154
if ( typeInstance instanceof TypeConfigurationAware configurationAware ) {
160155
configurationAware.setTypeConfiguration( typeConfiguration );
@@ -174,7 +169,7 @@ private static <T> BasicValue.Resolution<T> createResolution(
174169
@SuppressWarnings("unchecked")
175170
final UserType<T> userType = (UserType<T>) typeInstance;
176171
final CustomType<T> customType = new CustomType<>( userType, typeConfiguration );
177-
return new UserTypeResolution<>( customType, null, combinedTypeParameters, typeAnnotation );
172+
return new UserTypeResolution<>( customType, null, combinedTypeParameters );
178173
}
179174

180175
if ( typeInstance instanceof BasicType ) {
@@ -231,28 +226,6 @@ public MutabilityPlan<T> getMutabilityPlan() {
231226
return resolveLegacyCases( typeImplementorClass, indicators, typeConfiguration );
232227
}
233228

234-
private static <T> T instantiateType(
235-
String name, Class<T> typeImplementorClass, Annotation typeAnnotation,
236-
MetadataBuildingContext context, BootstrapContext bootstrapContext) {
237-
if ( typeAnnotation != null ) {
238-
// attempt to instantiate it with the annotation as a constructor argument
239-
try {
240-
final Constructor<T> constructor = typeImplementorClass.getConstructor( typeAnnotation.annotationType() );
241-
constructor.setAccessible( true );
242-
return constructor.newInstance( typeAnnotation );
243-
}
244-
catch ( NoSuchMethodException ignored ) {
245-
// no such constructor, instantiate it the old way
246-
}
247-
catch (InvocationTargetException|InstantiationException|IllegalAccessException e) {
248-
throw new org.hibernate.InstantiationException( "Could not instantiate custom type", typeImplementorClass, e );
249-
}
250-
}
251-
252-
return instantiateType( bootstrapContext.getServiceRegistry(), context.getBuildingOptions(),
253-
name, typeImplementorClass, bootstrapContext.getCustomTypeProducer() );
254-
}
255-
256229
private static <T> BasicValue.Resolution<T> resolveLegacyCases(
257230
Class<T> typeImplementorClass, JdbcTypeIndicators indicators, TypeConfiguration typeConfiguration) {
258231
final BasicType<T> legacyType;
@@ -345,14 +318,12 @@ public static BasicValue.Resolution<?> createLocalResolution(
345318
String name,
346319
Class<?> typeImplementorClass,
347320
Map<?,?> localTypeParams,
348-
Annotation typeAnnotation,
349321
MetadataBuildingContext buildingContext) {
350322
return createResolution(
351323
name + ':' + NAME_COUNTER.getAndIncrement(),
352324
typeImplementorClass,
353325
localTypeParams,
354326
null,
355-
typeAnnotation,
356327
buildingContext.getBootstrapContext().getTypeConfiguration().getCurrentBaseSqlTypeIndicators(),
357328
buildingContext
358329
);

hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/UserTypeResolution.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package org.hibernate.boot.model.process.internal;
66

7-
import java.lang.annotation.Annotation;
87
import java.util.Properties;
98

109
import org.hibernate.mapping.BasicValue;
@@ -28,16 +27,13 @@ public class UserTypeResolution<T> implements BasicValue.Resolution<T> {
2827
* and builds its own :(
2928
*/
3029
private final Properties combinedTypeParameters;
31-
private final Annotation typeAnnotation;
3230

3331
public UserTypeResolution(
3432
CustomType<T> userTypeAdapter,
3533
MutabilityPlan<T> explicitMutabilityPlan,
36-
Properties combinedTypeParameters,
37-
Annotation typeAnnotation) {
34+
Properties combinedTypeParameters) {
3835
this.userTypeAdapter = userTypeAdapter;
3936
this.combinedTypeParameters = combinedTypeParameters;
40-
this.typeAnnotation = typeAnnotation;
4137
this.mutabilityPlan = explicitMutabilityPlan != null
4238
? explicitMutabilityPlan
4339
: new UserTypeMutabilityPlanAdapter<>( userTypeAdapter.getUserType() );
@@ -81,10 +77,6 @@ public Properties getCombinedTypeParameters() {
8177
return combinedTypeParameters;
8278
}
8379

84-
public Annotation getTypeAnnotation() {
85-
return typeAnnotation;
86-
}
87-
8880
@Override
8981
public JdbcMapping getJdbcMapping() {
9082
return userTypeAdapter;

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,6 @@ private BasicType<?> resolveExplicitlyNamedAnyDiscriminatorType(
22612261
final BasicValue.Resolution<?> resolution = typeDefinition.resolve(
22622262
parameters,
22632263
null,
2264-
null,
22652264
metadataBuildingContext,
22662265
typeConfiguration.getCurrentBaseSqlTypeIndicators()
22672266
);

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,7 @@ private Resolution<?> buildResolution(Properties typeParameters) {
437437
explicitMutabilityPlanAccess,
438438
getAttributeConverterDescriptor(),
439439
typeParameters,
440-
getTypeAnnotation(),
441440
this::setTypeParameters,
442-
this::setTypeAnnotation,
443441
this,
444442
getBuildingContext()
445443
);
@@ -644,7 +642,7 @@ private Resolution<?> resolution(BasicJavaType explicitJavaType, JavaType<?> jav
644642
context.getTypeDefinitionRegistry().resolveAutoApplied( castType );
645643
if ( autoAppliedTypeDef != null ) {
646644
log.debug("BasicValue resolution matched auto-applied type-definition");
647-
return autoAppliedTypeDef.resolve( getTypeParameters(), null, null, context, this );
645+
return autoAppliedTypeDef.resolve( getTypeParameters(), null, context, this );
648646
}
649647
}
650648

@@ -812,9 +810,7 @@ private static Resolution<?> interpretExplicitlyNamedType(
812810
Function<TypeConfiguration, MutabilityPlan> explicitMutabilityPlanAccess,
813811
ConverterDescriptor converterDescriptor,
814812
Map<Object,Object> localTypeParams,
815-
Annotation typeAnnotation,
816813
Consumer<Properties> combinedParameterConsumer,
817-
Consumer<Annotation> annotationConsumer,
818814
JdbcTypeIndicators stdIndicators,
819815
MetadataBuildingContext context) {
820816

@@ -897,14 +893,12 @@ public TypeConfiguration getTypeConfiguration() {
897893
if ( typeDefinition != null ) {
898894
final Resolution<?> resolution = typeDefinition.resolve(
899895
localTypeParams,
900-
typeAnnotation,
901896
explicitMutabilityPlanAccess != null
902897
? explicitMutabilityPlanAccess.apply( typeConfiguration )
903898
: null,
904899
context,
905900
stdIndicators
906901
);
907-
annotationConsumer.accept( resolution.getTypeAnnotation() );
908902
combinedParameterConsumer.accept( resolution.getCombinedTypeParameters() );
909903
return resolution;
910904
}
@@ -920,7 +914,6 @@ public TypeConfiguration getTypeConfiguration() {
920914
context.getTypeDefinitionRegistry().register( implicitDefinition );
921915
return implicitDefinition.resolve(
922916
localTypeParams,
923-
typeAnnotation,
924917
explicitMutabilityPlanAccess != null
925918
? explicitMutabilityPlanAccess.apply( typeConfiguration )
926919
: null,
@@ -929,7 +922,7 @@ public TypeConfiguration getTypeConfiguration() {
929922
);
930923
}
931924

932-
return TypeDefinition.createLocalResolution( name, typeNamedClass, localTypeParams, typeAnnotation, context );
925+
return TypeDefinition.createLocalResolution( name, typeNamedClass, localTypeParams, context );
933926
}
934927
catch (ClassLoadingException e) {
935928
// allow the exception below to trigger
@@ -1039,8 +1032,7 @@ public void setExplicitCustomType(Class<? extends UserType<?>> explicitCustomTyp
10391032
getTypeConfiguration()
10401033
),
10411034
null,
1042-
typeProperties,
1043-
typeAnnotation
1035+
typeProperties
10441036
);
10451037
}
10461038
}
@@ -1179,10 +1171,6 @@ default Properties getCombinedTypeParameters() {
11791171
return null;
11801172
}
11811173

1182-
default Annotation getTypeAnnotation() {
1183-
return null;
1184-
}
1185-
11861174
JdbcMapping getJdbcMapping();
11871175

11881176
/**

0 commit comments

Comments
 (0)