@@ -102,7 +102,8 @@ public enum Kind {
102102 // in-flight info
103103
104104 private Class <? extends UserType <?>> explicitCustomType ;
105- private Map <String ,String > explicitLocalTypeParams ;
105+ private Map <String ,String > explicitLocalCustomTypeParams ;
106+ private Annotation explicitCustomTypeAnnotation ;
106107
107108 private Function <TypeConfiguration , JdbcType > explicitJdbcTypeAccess ;
108109 private Function <TypeConfiguration , BasicJavaType <?>> explicitJavaTypeAccess ;
@@ -338,8 +339,9 @@ private boolean applyCustomType(MemberDetails memberDetails, TypeDetails typeDet
338339 final var modelContext = getSourceModelContext ();
339340 final var userTypeImpl = kind .mappingAccess .customType ( memberDetails , modelContext );
340341 if ( userTypeImpl != null ) {
341- applyExplicitType ( userTypeImpl ,
342- kind .mappingAccess .customTypeParameters ( memberDetails , modelContext ) );
342+ this .explicitCustomType = userTypeImpl ;
343+ this .explicitLocalCustomTypeParams = kind .mappingAccess .customTypeParameters ( memberDetails , modelContext );
344+ this .explicitCustomTypeAnnotation = kind .mappingAccess .customTypeAnnotation ( memberDetails , modelContext );
343345 // An explicit custom UserType has top precedence when we get to BasicValue resolution.
344346 return true ;
345347 }
@@ -349,7 +351,8 @@ private boolean applyCustomType(MemberDetails memberDetails, TypeDetails typeDet
349351 final var registeredUserTypeImpl =
350352 getMetadataCollector ().findRegisteredUserType ( basicClass );
351353 if ( registeredUserTypeImpl != null ) {
352- applyExplicitType ( registeredUserTypeImpl , emptyMap () );
354+ this .explicitCustomType = registeredUserTypeImpl ;
355+ this .explicitLocalCustomTypeParams = emptyMap ();
353356 return true ;
354357 }
355358 }
@@ -384,11 +387,6 @@ private void prepareValue(MemberDetails value, TypeDetails typeDetails, @Nullabl
384387 }
385388 }
386389
387- private void applyExplicitType (Class <? extends UserType <?>> userTypeImpl , Map <String ,String > parameters ) {
388- explicitCustomType = userTypeImpl ;
389- explicitLocalTypeParams = parameters ;
390- }
391-
392390 private void prepareCollectionId (MemberDetails attribute ) {
393391 final var collectionId = attribute .getDirectAnnotationUsage ( CollectionId .class );
394392 if ( collectionId == null ) {
@@ -1195,7 +1193,7 @@ else if ( aggregateComponent != null ) {
11951193 }
11961194
11971195 public void fillSimpleValue () {
1198- basicValue .setExplicitTypeParams ( explicitLocalTypeParams );
1196+ basicValue .setExplicitTypeParams ( explicitLocalCustomTypeParams );
11991197
12001198 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12011199 // todo (6.0) : we are dropping support for @Type and @TypeDef from annotations
@@ -1211,6 +1209,10 @@ public void fillSimpleValue() {
12111209 basicValue .setTypeParameters ( createDynamicParameterizedTypeParameters () );
12121210 }
12131211
1212+ if ( explicitCustomType != null ) {
1213+ basicValue .setTypeAnnotation ( explicitCustomTypeAnnotation );
1214+ }
1215+
12141216 if ( converterDescriptor != null ) {
12151217 basicValue .setJpaAttributeConverterDescriptor ( converterDescriptor );
12161218 }
@@ -1282,8 +1284,8 @@ private Map<String, Object> createDynamicParameterizedTypeParameters() {
12821284 parameters .put ( DynamicParameterizedType .ACCESS_TYPE , accessType .getType () );
12831285 }
12841286
1285- if ( explicitLocalTypeParams != null ) {
1286- parameters .putAll ( explicitLocalTypeParams );
1287+ if ( explicitLocalCustomTypeParams != null ) {
1288+ parameters .putAll ( explicitLocalCustomTypeParams );
12871289 }
12881290
12891291 return parameters ;
@@ -1295,6 +1297,7 @@ private Map<String, Object> createDynamicParameterizedTypeParameters() {
12951297 private interface BasicMappingAccess {
12961298 Class <? extends UserType <?>> customType (MemberDetails attribute , ModelsContext context );
12971299 Map <String ,String > customTypeParameters (MemberDetails attribute , ModelsContext context );
1300+ Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context );
12981301 }
12991302
13001303 private static class ValueMappingAccess implements BasicMappingAccess {
@@ -1311,6 +1314,12 @@ public Map<String,String> customTypeParameters(MemberDetails attribute, ModelsCo
13111314 final var customType = attribute .locateAnnotationUsage ( Type .class , context );
13121315 return customType == null ? null : extractParameterMap ( customType .parameters () );
13131316 }
1317+
1318+ @ Override
1319+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1320+ final var annotations = attribute .getMetaAnnotated ( Type .class , context );
1321+ return annotations == null || annotations .isEmpty () ? null : annotations .get ( 0 );
1322+ }
13141323 }
13151324
13161325 private static class AnyDiscriminatorMappingAccess implements BasicMappingAccess {
@@ -1325,6 +1334,11 @@ public Class<? extends UserType<?>> customType(MemberDetails attribute, ModelsCo
13251334 public Map <String ,String > customTypeParameters (MemberDetails attribute , ModelsContext context ) {
13261335 return emptyMap ();
13271336 }
1337+
1338+ @ Override
1339+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1340+ return null ;
1341+ }
13281342 }
13291343
13301344 private static class AnyKeyMappingAccess implements BasicMappingAccess {
@@ -1339,6 +1353,11 @@ public Class<? extends UserType<?>> customType(MemberDetails attribute, ModelsCo
13391353 public Map <String ,String > customTypeParameters (MemberDetails attribute , ModelsContext context ) {
13401354 return emptyMap ();
13411355 }
1356+
1357+ @ Override
1358+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1359+ return null ;
1360+ }
13421361 }
13431362
13441363 private static class MapKeyMappingAccess implements BasicMappingAccess {
@@ -1357,6 +1376,12 @@ public Map<String,String> customTypeParameters(MemberDetails attribute, ModelsCo
13571376 return customType == null ? null : extractParameterMap ( customType .parameters () );
13581377
13591378 }
1379+
1380+ @ Override
1381+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1382+ final var annotations = attribute .getMetaAnnotated ( MapKeyType .class , context );
1383+ return annotations == null || annotations .isEmpty () ? null : annotations .get ( 0 );
1384+ }
13601385 }
13611386
13621387 private static class CollectionIdMappingAccess implements BasicMappingAccess {
@@ -1373,7 +1398,12 @@ public Class<? extends UserType<?>> customType(MemberDetails attribute, ModelsCo
13731398 public Map <String ,String > customTypeParameters (MemberDetails attribute , ModelsContext context ) {
13741399 final var customType = attribute .locateAnnotationUsage ( CollectionIdType .class , context );
13751400 return customType == null ? null : extractParameterMap ( customType .parameters () );
1401+ }
13761402
1403+ @ Override
1404+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1405+ final var annotations = attribute .getMetaAnnotated ( CollectionIdType .class , context );
1406+ return annotations == null || annotations .isEmpty () ? null : annotations .get ( 0 );
13771407 }
13781408 }
13791409
@@ -1389,6 +1419,11 @@ public Class<? extends UserType<?>> customType(MemberDetails attribute, ModelsCo
13891419 public Map <String ,String > customTypeParameters (MemberDetails attribute , ModelsContext context ) {
13901420 return emptyMap ();
13911421 }
1422+
1423+ @ Override
1424+ public Annotation customTypeAnnotation (MemberDetails attribute , ModelsContext context ) {
1425+ return null ;
1426+ }
13921427 }
13931428
13941429 private static AnnotatedJoinColumns convertToJoinColumns (AnnotatedColumns columns , MetadataBuildingContext context ) {
0 commit comments