178178import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
179179import static org .hibernate .internal .util .StringHelper .nullIfEmpty ;
180180import static org .hibernate .internal .util .StringHelper .qualify ;
181+ import static org .hibernate .internal .util .collections .CollectionHelper .isEmpty ;
181182import static org .hibernate .mapping .MappingHelper .createLocalUserCollectionTypeBean ;
182183
183184/**
@@ -392,7 +393,7 @@ private static AnnotatedJoinColumns mapKeyJoinColumns(
392393 MemberDetails property ) {
393394// Comment comment) {
394395 return buildJoinColumnsWithDefaultColumnSuffix (
395- mapKeyJoinColumnAnnotations ( propertyHolder , inferredData , property , context ),
396+ mapKeyJoinColumnAnnotations ( property , context ),
396397// comment,
397398 null ,
398399 entityBinder .getSecondaryTables (),
@@ -560,13 +561,8 @@ private static boolean hasMapKeyAnnotation(MemberDetails property) {
560561 }
561562
562563 private static boolean isToManyAssociationWithinEmbeddableCollection (PropertyHolder propertyHolder ) {
563- if ( propertyHolder instanceof ComponentPropertyHolder ) {
564- ComponentPropertyHolder componentPropertyHolder = (ComponentPropertyHolder ) propertyHolder ;
565- return componentPropertyHolder .isWithinElementCollection ();
566- }
567- else {
568- return false ;
569- }
564+ return propertyHolder instanceof ComponentPropertyHolder componentPropertyHolder
565+ && componentPropertyHolder .isWithinElementCollection ();
570566 }
571567
572568 private static AnnotatedColumns elementColumns (
@@ -626,16 +622,14 @@ else if ( property.hasDirectAnnotationUsage( Columns.class ) ) {
626622 }
627623
628624 private static JoinColumn [] mapKeyJoinColumnAnnotations (
629- PropertyHolder propertyHolder ,
630- PropertyData inferredData ,
631625 MemberDetails property ,
632626 MetadataBuildingContext context ) {
633627 final MapKeyJoinColumn [] mapKeyJoinColumns = property .getRepeatedAnnotationUsages (
634628 JpaAnnotations .MAP_KEY_JOIN_COLUMN ,
635629 context .getMetadataCollector ().getSourceModelBuildingContext ()
636630 );
637631
638- if ( CollectionHelper . isEmpty ( mapKeyJoinColumns ) ) {
632+ if ( isEmpty ( mapKeyJoinColumns ) ) {
639633 return null ;
640634 }
641635
@@ -945,7 +939,7 @@ private static CollectionBinder createBinderFromCustomTypeAnnotation(
945939 MemberDetails property ,
946940 CollectionType typeAnnotation ,
947941 MetadataBuildingContext buildingContext ) {
948- determineSemanticJavaType ( property , buildingContext );
942+ determineSemanticJavaType ( property );
949943 final ManagedBean <? extends UserCollectionType > customTypeBean = resolveCustomType (
950944 property ,
951945 typeAnnotation ,
@@ -1014,7 +1008,7 @@ private static CollectionClassification determineCollectionClassification(
10141008 final SourceModelBuildingContext sourceModelContext = buildingContext .getMetadataCollector ().getSourceModelBuildingContext ();
10151009
10161010 if ( !property .hasAnnotationUsage ( Bag .class , sourceModelContext ) ) {
1017- return determineCollectionClassification ( determineSemanticJavaType ( property , buildingContext ), property , buildingContext );
1011+ return determineCollectionClassification ( determineSemanticJavaType ( property ), property , buildingContext );
10181012 }
10191013
10201014 if ( property .hasAnnotationUsage ( OrderColumn .class , sourceModelContext ) ) {
@@ -1126,7 +1120,7 @@ private static CollectionClassification determineCollectionClassification(
11261120 return null ;
11271121 }
11281122
1129- private static Class <?> determineSemanticJavaType (MemberDetails property , MetadataBuildingContext buildingContext ) {
1123+ private static Class <?> determineSemanticJavaType (MemberDetails property ) {
11301124 if ( property .isPlural () ) {
11311125 final ClassDetails collectionClassDetails = property .getType ().determineRawClass ();
11321126 final Class <?> collectionClass = collectionClassDetails .toJavaClass ();
@@ -1536,25 +1530,23 @@ private void handleFetch() {
15361530
15371531 private void setHibernateFetchMode (org .hibernate .annotations .FetchMode fetchMode ) {
15381532 switch ( fetchMode ) {
1539- case JOIN -> {
1533+ case JOIN :
15401534 collection .setFetchMode ( FetchMode .JOIN );
15411535 collection .setLazy ( false );
1542- }
1543- case SELECT -> {
1536+ break ;
1537+ case SELECT :
15441538 collection .setFetchMode ( FetchMode .SELECT );
1545- }
1546- case SUBSELECT -> {
1539+ break ;
1540+ case SUBSELECT :
15471541 collection .setFetchMode ( FetchMode .SELECT );
15481542 collection .setSubselectLoadable ( true );
15491543 collection .getOwner ().setSubselectLoadableCollections ( true );
1550- }
1551- default -> {
1544+ break ;
1545+ default :
15521546 throw new AssertionFailure ( "unknown fetch type" );
1553- }
15541547 }
15551548 }
15561549
1557- @ SuppressWarnings ("deprecation" )
15581550 private void handleLazy () {
15591551 final FetchType jpaFetchType = getJpaFetchType ();
15601552 collection .setLazy ( jpaFetchType == LAZY );
@@ -1877,7 +1869,6 @@ private String getWhereOnCollectionClause() {
18771869 }
18781870
18791871 private String getWhereOnClassClause () {
1880- final TypeDetails elementType = property .getElementType ();
18811872 final SQLRestriction restrictionOnClass = getOverridableAnnotation (
18821873 property .getAssociatedType ().determineRawClass (),
18831874 SQLRestriction .class ,
@@ -2010,7 +2001,7 @@ private static String buildOrderById(PersistentClass associatedClass, String ord
20102001 public static String adjustUserSuppliedValueCollectionOrderingFragment (String orderByFragment ) {
20112002 if ( orderByFragment != null ) {
20122003 orderByFragment = orderByFragment .trim ();
2013- if ( orderByFragment .length () == 0 || orderByFragment .equalsIgnoreCase ( "asc" ) ) {
2004+ if ( orderByFragment .isEmpty () || orderByFragment .equalsIgnoreCase ( "asc" ) ) {
20142005 // This indicates something like either:
20152006 // `@OrderBy()`
20162007 // `@OrderBy("asc")
@@ -2071,7 +2062,6 @@ private DependantValue buildCollectionKey(AnnotatedJoinColumns joinColumns, OnDe
20712062 if ( key .getForeignKeyName () == null
20722063 && key .getForeignKeyDefinition () == null
20732064 && collectionTableAnn .joinColumns ().length == 1 ) {
2074- //noinspection unchecked
20752065 final JoinColumn joinColumn = collectionTableAnn .joinColumns ()[0 ];
20762066 final ForeignKey nestedForeignKey = joinColumn .foreignKey ();
20772067 key .setForeignKeyName ( nullIfEmpty ( nestedForeignKey .name () ) );
@@ -2237,12 +2227,13 @@ private void handleElementCollection(TypeDetails elementType, String hqlOrderBy)
22372227 buildingContext
22382228 );
22392229
2240- final Class <? extends CompositeUserType <?>> compositeUserType = resolveCompositeUserType ( property , elementClass , buildingContext );
2241- boolean isComposite = classType == EMBEDDABLE || compositeUserType != null ;
2230+ final Class <? extends CompositeUserType <?>> compositeUserType =
2231+ resolveCompositeUserType ( property , elementClass , buildingContext );
2232+ final boolean isComposite = classType == EMBEDDABLE || compositeUserType != null ;
22422233 holder .prepare ( property , isComposite );
22432234
22442235 if ( isComposite ) {
2245- handleCompositeCollectionElement ( hqlOrderBy , elementType , elementClass , holder , compositeUserType );
2236+ handleCompositeCollectionElement ( hqlOrderBy , elementType , holder , compositeUserType );
22462237 }
22472238 else {
22482239 handleCollectionElement ( elementType , hqlOrderBy , elementClass , holder );
@@ -2283,7 +2274,6 @@ private void handleCollectionElement(
22832274 private void handleCompositeCollectionElement (
22842275 String hqlOrderBy ,
22852276 TypeDetails elementType ,
2286- ClassDetails elementClass ,
22872277 CollectionPropertyHolder holder ,
22882278 Class <? extends CompositeUserType <?>> compositeUserType ) {
22892279 //TODO be smart with isNullable
@@ -2555,7 +2545,7 @@ private static void addCheckToCollection(Table collectionTable, Check check) {
25552545 private void processSoftDeletes () {
25562546 assert collection .getCollectionTable () != null ;
25572547
2558- final SoftDelete softDelete = extractSoftDelete ( property , propertyHolder , buildingContext );
2548+ final SoftDelete softDelete = extractSoftDelete ( property , buildingContext );
25592549 if ( softDelete == null ) {
25602550 return ;
25612551 }
@@ -2568,20 +2558,18 @@ private void processSoftDeletes() {
25682558 );
25692559 }
25702560
2571- private static SoftDelete extractSoftDelete (
2572- MemberDetails property ,
2573- PropertyHolder propertyHolder ,
2574- MetadataBuildingContext context ) {
2561+ private static SoftDelete extractSoftDelete (MemberDetails property , MetadataBuildingContext context ) {
25752562 final SoftDelete fromProperty = property .getDirectAnnotationUsage ( SoftDelete .class );
25762563 if ( fromProperty != null ) {
25772564 return fromProperty ;
25782565 }
2579-
2580- return extractFromPackage (
2581- SoftDelete .class ,
2582- property .getDeclaringType (),
2583- context
2584- );
2566+ else {
2567+ return extractFromPackage (
2568+ SoftDelete .class ,
2569+ property .getDeclaringType (),
2570+ context
2571+ );
2572+ }
25852573 }
25862574
25872575 private void handleUnownedManyToMany (
0 commit comments