@@ -461,8 +461,7 @@ private static <X, Y> AttributeMetadata<X, Y> determineAttributeMetadata(
461461 propertyMapping ,
462462 attributeContext .getOwnerType (),
463463 member ,
464- AttributeClassification .ANY ,
465- context
464+ AttributeClassification .ANY
466465 );
467466 }
468467 else if ( type instanceof EntityType ) {
@@ -471,8 +470,7 @@ else if ( type instanceof EntityType ) {
471470 propertyMapping ,
472471 attributeContext .getOwnerType (),
473472 member ,
474- determineSingularAssociationClassification ( member ),
475- context
473+ determineSingularAssociationClassification ( member )
476474 );
477475 }
478476 else if ( type instanceof CollectionType ) {
@@ -486,8 +484,7 @@ else if ( type instanceof CollectionType ) {
486484 member ,
487485 collectionClassification ( elementType , isManyToMany ),
488486 elementClassification ( elementType , isManyToMany ),
489- indexClassification ( value ),
490- context
487+ indexClassification ( value )
491488 );
492489 }
493490 else if ( value instanceof OneToMany ) {
@@ -516,8 +513,7 @@ else if ( type instanceof ComponentType ) {
516513 propertyMapping ,
517514 attributeContext .getOwnerType (),
518515 member ,
519- AttributeClassification .EMBEDDED ,
520- context
516+ AttributeClassification .EMBEDDED
521517 );
522518 }
523519 else {
@@ -527,8 +523,7 @@ else if ( type instanceof ComponentType ) {
527523 propertyMapping ,
528524 attributeContext .getOwnerType (),
529525 member ,
530- AttributeClassification .BASIC ,
531- context
526+ AttributeClassification .BASIC
532527 );
533528 }
534529 throw new UnsupportedMappingException ( "oops, we are missing something: " + propertyMapping );
@@ -557,9 +552,9 @@ else if ( elementType instanceof ComponentType ) {
557552 return AttributeClassification .EMBEDDED ;
558553 }
559554 else if ( elementType instanceof EntityType ) {
560- return isManyToMany ?
561- AttributeClassification .MANY_TO_MANY :
562- AttributeClassification .ONE_TO_MANY ;
555+ return isManyToMany
556+ ? AttributeClassification .MANY_TO_MANY
557+ : AttributeClassification .ONE_TO_MANY ;
563558 }
564559 else {
565560 return AttributeClassification .BASIC ;
@@ -569,9 +564,9 @@ else if ( elementType instanceof EntityType ) {
569564 private static AttributeClassification collectionClassification (
570565 org .hibernate .type .Type elementType , boolean isManyToMany ) {
571566 if ( elementType instanceof EntityType ) {
572- return isManyToMany ?
573- AttributeClassification .MANY_TO_MANY :
574- AttributeClassification .ONE_TO_MANY ;
567+ return isManyToMany
568+ ? AttributeClassification .MANY_TO_MANY
569+ : AttributeClassification .ONE_TO_MANY ;
575570 }
576571 else {
577572 return AttributeClassification .ELEMENT_COLLECTION ;
@@ -680,7 +675,7 @@ private static EmbeddableRepresentationStrategy ownerRepresentationStrategy(
680675 return ownerBootDescriptor .getBuildingContext ()
681676 .getBootstrapContext ()
682677 .getRepresentationStrategySelector ()
683- .resolveStrategy (ownerBootDescriptor , null ,
678+ .resolveStrategy ( ownerBootDescriptor , null ,
684679 metadataContext .getRuntimeModelCreationContext () );
685680 }
686681 else {
@@ -728,66 +723,49 @@ private static Member resolveVirtualIdentifierMember( Property property, EntityP
728723 final ManagedDomainType <?> ownerType = attributeContext .getOwnerType ();
729724 final Property property = attributeContext .getPropertyMapping ();
730725 final Type .PersistenceType persistenceType = ownerType .getPersistenceType ();
731- if ( Type .PersistenceType .EMBEDDABLE == persistenceType ) {
732- return embeddedMemberResolver .resolveMember ( attributeContext , metadataContext );
733- }
734- else if ( Type .PersistenceType .MAPPED_SUPERCLASS == persistenceType ) {
735- return resolveMappedSuperclassMember (
736- property ,
737- (MappedSuperclassDomainType <?>) ownerType ,
738- metadataContext
739- );
740- }
741- else if ( Type .PersistenceType .ENTITY == persistenceType ) {
742- return resolveEntityMember ( property , getDeclaringEntity ( (AbstractIdentifiableType <?>) ownerType , metadataContext ) );
743- }
744- else {
745- throw new IllegalArgumentException ( "Unexpected owner type : " + persistenceType );
746- }
726+ return switch ( persistenceType ) {
727+ case ENTITY ->
728+ resolveEntityMember ( property ,
729+ getDeclaringEntity ( (AbstractIdentifiableType <?>) ownerType , metadataContext ) );
730+ case MAPPED_SUPERCLASS ->
731+ resolveMappedSuperclassMember ( property , (MappedSuperclassDomainType <?>) ownerType , metadataContext );
732+ case EMBEDDABLE ->
733+ embeddedMemberResolver .resolveMember ( attributeContext , metadataContext );
734+ default -> throw new IllegalArgumentException ( "Unexpected owner type : " + persistenceType );
735+ };
747736 };
748737
749738 private static Member resolveEntityMember (Property property , EntityPersister declaringEntity ) {
750739 final String propertyName = property .getName ();
751740 final AttributeMapping attributeMapping = declaringEntity .findAttributeMapping ( propertyName );
752- if ( attributeMapping == null ) {
753- // just like in #determineIdentifierJavaMember , this *should* indicate we have an IdClass mapping
754- return resolveVirtualIdentifierMember ( property , declaringEntity );
755- }
756- else {
757- final Getter getter = getter ( declaringEntity , property );
758- return getter instanceof PropertyAccessMapImpl .GetterImpl
759- ? new MapMember ( propertyName , property .getType ().getReturnedClass () )
760- : getter .getMember ();
761- }
741+ return attributeMapping == null
742+ // just like in #determineIdentifierJavaMember , this *should* indicate we have an IdClass mapping
743+ ? resolveVirtualIdentifierMember ( property , declaringEntity )
744+ : getter ( declaringEntity , property , propertyName , property .getType ().getReturnedClass () );
762745 }
763746
764747 private static Member resolveMappedSuperclassMember (
765748 Property property ,
766749 MappedSuperclassDomainType <?> ownerType ,
767- MetadataContext metadataContext ) {
768- final EntityPersister declaringEntity = getDeclaringEntity ( (AbstractIdentifiableType <?>) ownerType , metadataContext );
750+ MetadataContext context ) {
751+ final EntityPersister declaringEntity =
752+ getDeclaringEntity ( (AbstractIdentifiableType <?>) ownerType , context );
769753 if ( declaringEntity != null ) {
770754 return resolveEntityMember ( property , declaringEntity );
771755 }
772756 else {
773757 final ManagedDomainType <?> subType = ownerType .getSubTypes ().iterator ().next ();
774758 final Type .PersistenceType persistenceType = subType .getPersistenceType ();
775- if ( persistenceType == Type .PersistenceType .ENTITY ) {
776- return resolveEntityMember ( property , getDeclaringEntity ( (AbstractIdentifiableType <?>) subType , metadataContext ) );
777- }
778- else if ( persistenceType == Type .PersistenceType .EMBEDDABLE ) {
779- return resolveEmbeddedMember ( property , (EmbeddableDomainType <?>) subType , metadataContext );
780- }
781- else if ( persistenceType == Type .PersistenceType .MAPPED_SUPERCLASS ) {
782- return resolveMappedSuperclassMember (
783- property ,
784- (MappedSuperclassDomainType <?>) subType ,
785- metadataContext
786- );
787- }
788- else {
789- throw new IllegalArgumentException ( "Unexpected subtype: " + persistenceType );
790- }
759+ return switch ( persistenceType ) {
760+ case ENTITY ->
761+ resolveEntityMember ( property ,
762+ getDeclaringEntity ( (AbstractIdentifiableType <?>) subType , context ) );
763+ case MAPPED_SUPERCLASS ->
764+ resolveMappedSuperclassMember ( property , (MappedSuperclassDomainType <?>) subType , context );
765+ case EMBEDDABLE ->
766+ resolveEmbeddedMember ( property , (EmbeddableDomainType <?>) subType , context );
767+ default -> throw new IllegalArgumentException ( "Unexpected PersistenceType: " + persistenceType );
768+ };
791769 }
792770 }
793771
@@ -797,18 +775,12 @@ else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) {
797775 final EntityPersister declaringEntityMapping = getDeclaringEntity ( identifiableType , metadataContext );
798776 final EntityIdentifierMapping identifierMapping = declaringEntityMapping .getIdentifierMapping ();
799777 final Property propertyMapping = attributeContext .getPropertyMapping ();
800- if ( !propertyMapping .getName ().equals ( identifierMapping .getAttributeName () ) ) {
801- // this *should* indicate processing part of an IdClass...
802- return virtualIdentifierMemberResolver .resolveMember ( attributeContext , metadataContext );
803- }
778+ return !propertyMapping .getName ().equals ( identifierMapping .getAttributeName () )
779+ // this *should* indicate processing part of an IdClass...
780+ ? virtualIdentifierMemberResolver .resolveMember ( attributeContext , metadataContext )
781+ : getter ( declaringEntityMapping , propertyMapping ,
782+ identifierMapping .getAttributeName (), identifierMapping .getJavaType ().getJavaTypeClass () );
804783
805- final Getter getter = getter ( declaringEntityMapping , propertyMapping );
806- if ( getter instanceof PropertyAccessMapImpl .GetterImpl ) {
807- return new MapMember ( identifierMapping .getAttributeName (), identifierMapping .getJavaType ().getJavaTypeClass () );
808- }
809- else {
810- return getter .getMember ();
811- }
812784 };
813785
814786 private final MemberResolver versionMemberResolver = (attributeContext , metadataContext ) -> {
@@ -824,20 +796,20 @@ else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) {
824796 // this should never happen, but to be safe...
825797 throw new IllegalArgumentException ( "Given property did not match declared version property" );
826798 }
827-
828- final Getter getter = getter ( entityPersister , attributeContext .getPropertyMapping () );
829- if ( getter instanceof PropertyAccessMapImpl .GetterImpl ) {
830- return new MapMember ( versionPropertyName , versionMapping .getJavaType ().getJavaTypeClass () );
831- }
832- else {
833- return getter .getMember ();
834- }
799+ return getter ( entityPersister , attributeContext .getPropertyMapping (),
800+ versionPropertyName , versionMapping .getJavaType ().getJavaTypeClass () );
835801 };
836802
837- private static Getter getter (EntityPersister declaringEntityMapping , Property propertyMapping ) {
838- return declaringEntityMapping .getRepresentationStrategy ()
839- .resolvePropertyAccess ( propertyMapping )
840- .getGetter ();
803+ private static Member getter (EntityPersister persister , Property property , String name , Class <?> type ) {
804+ final Getter getter = getter ( persister , property );
805+ return getter instanceof PropertyAccessMapImpl .GetterImpl
806+ ? new MapMember ( name , type )
807+ : getter .getMember ();
841808 }
842809
810+ private static Getter getter (EntityPersister persister , Property property ) {
811+ return persister .getRepresentationStrategy ()
812+ .resolvePropertyAccess ( property )
813+ .getGetter ();
814+ }
843815}
0 commit comments