Skip to content

Commit

Permalink
HHH-17941 - Apply incremental categorization to "annotation binding" …
Browse files Browse the repository at this point in the history
…- managed-type and persistent-attribute metadata
  • Loading branch information
sebersole committed Apr 19, 2024
1 parent e91f4ce commit 3ed13f9
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jakarta.persistence.AccessType;
import jakarta.persistence.Basic;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.ManyToMany;
Expand Down Expand Up @@ -134,7 +135,11 @@ public static AttributeMetadata.AttributeNature determineAttributeNature(ClassDe
|| elementCollection != null
|| manyToAny != null;

final boolean implicitlyBasic = backingMember.getAnnotationUsage( JpaAnnotations.TEMPORAL ) != null
final boolean specifiesJdbcType = backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE_CODE ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE ) != null;

final boolean implicitlyBasic = specifiesJdbcType
|| backingMember.getAnnotationUsage( JpaAnnotations.TEMPORAL ) != null
|| backingMember.getAnnotationUsage( JpaAnnotations.LOB ) != null
|| backingMember.getAnnotationUsage( JpaAnnotations.ENUMERATED ) != null
|| backingMember.getAnnotationUsage( JpaAnnotations.VERSION ) != null
Expand All @@ -144,11 +149,12 @@ public static AttributeMetadata.AttributeNature determineAttributeNature(ClassDe
|| backingMember.getAnnotationUsage( HibernateAnnotations.TZ_STORAGE ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.TYPE ) != null
|| backingMember.getAnnotationUsage( TenantId.class ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.JAVA_TYPE ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE_CODE ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.JDBC_TYPE ) != null;
|| backingMember.getAnnotationUsage( HibernateAnnotations.JAVA_TYPE ) != null;

final boolean implicitlyEmbedded = backingMember.getAnnotationUsage( HibernateAnnotations.EMBEDDABLE_INSTANTIATOR ) != null
final boolean refersToEmbeddable = backingMember.getType().determineRawClass().hasAnnotationUsage( Embeddable.class );

final boolean implicitlyEmbedded = refersToEmbeddable
|| backingMember.getAnnotationUsage( HibernateAnnotations.EMBEDDABLE_INSTANTIATOR ) != null
|| backingMember.getAnnotationUsage( HibernateAnnotations.COMPOSITE_TYPE ) != null;

final boolean implicitlyAny = backingMember.getAnnotationUsage( HibernateAnnotations.ANY_DISCRIMINATOR ) != null
Expand All @@ -162,7 +168,13 @@ public static AttributeMetadata.AttributeNature determineAttributeNature(ClassDe
if ( !plural ) {
// first implicit basic nature
if ( implicitlyBasic ) {
natures.add( AttributeMetadata.AttributeNature.BASIC );
if ( specifiesJdbcType && implicitlyEmbedded ) {
// special case for embedded and JSON...
// don't infer BASIC
}
else {
natures.add( AttributeMetadata.AttributeNature.BASIC );
}
}

// then embedded
Expand Down

0 comments on commit 3ed13f9

Please sign in to comment.