178
178
import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
179
179
import static org .hibernate .internal .util .StringHelper .nullIfEmpty ;
180
180
import static org .hibernate .internal .util .StringHelper .qualify ;
181
+ import static org .hibernate .internal .util .collections .CollectionHelper .isEmpty ;
181
182
import static org .hibernate .mapping .MappingHelper .createLocalUserCollectionTypeBean ;
182
183
183
184
/**
@@ -392,7 +393,7 @@ private static AnnotatedJoinColumns mapKeyJoinColumns(
392
393
MemberDetails property ) {
393
394
// Comment comment) {
394
395
return buildJoinColumnsWithDefaultColumnSuffix (
395
- mapKeyJoinColumnAnnotations ( propertyHolder , inferredData , property , context ),
396
+ mapKeyJoinColumnAnnotations ( property , context ),
396
397
// comment,
397
398
null ,
398
399
entityBinder .getSecondaryTables (),
@@ -560,13 +561,8 @@ private static boolean hasMapKeyAnnotation(MemberDetails property) {
560
561
}
561
562
562
563
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 ();
570
566
}
571
567
572
568
private static AnnotatedColumns elementColumns (
@@ -626,16 +622,14 @@ else if ( property.hasDirectAnnotationUsage( Columns.class ) ) {
626
622
}
627
623
628
624
private static JoinColumn [] mapKeyJoinColumnAnnotations (
629
- PropertyHolder propertyHolder ,
630
- PropertyData inferredData ,
631
625
MemberDetails property ,
632
626
MetadataBuildingContext context ) {
633
627
final MapKeyJoinColumn [] mapKeyJoinColumns = property .getRepeatedAnnotationUsages (
634
628
JpaAnnotations .MAP_KEY_JOIN_COLUMN ,
635
629
context .getMetadataCollector ().getSourceModelBuildingContext ()
636
630
);
637
631
638
- if ( CollectionHelper . isEmpty ( mapKeyJoinColumns ) ) {
632
+ if ( isEmpty ( mapKeyJoinColumns ) ) {
639
633
return null ;
640
634
}
641
635
@@ -945,7 +939,7 @@ private static CollectionBinder createBinderFromCustomTypeAnnotation(
945
939
MemberDetails property ,
946
940
CollectionType typeAnnotation ,
947
941
MetadataBuildingContext buildingContext ) {
948
- determineSemanticJavaType ( property , buildingContext );
942
+ determineSemanticJavaType ( property );
949
943
final ManagedBean <? extends UserCollectionType > customTypeBean = resolveCustomType (
950
944
property ,
951
945
typeAnnotation ,
@@ -1014,7 +1008,7 @@ private static CollectionClassification determineCollectionClassification(
1014
1008
final SourceModelBuildingContext sourceModelContext = buildingContext .getMetadataCollector ().getSourceModelBuildingContext ();
1015
1009
1016
1010
if ( !property .hasAnnotationUsage ( Bag .class , sourceModelContext ) ) {
1017
- return determineCollectionClassification ( determineSemanticJavaType ( property , buildingContext ), property , buildingContext );
1011
+ return determineCollectionClassification ( determineSemanticJavaType ( property ), property , buildingContext );
1018
1012
}
1019
1013
1020
1014
if ( property .hasAnnotationUsage ( OrderColumn .class , sourceModelContext ) ) {
@@ -1126,7 +1120,7 @@ private static CollectionClassification determineCollectionClassification(
1126
1120
return null ;
1127
1121
}
1128
1122
1129
- private static Class <?> determineSemanticJavaType (MemberDetails property , MetadataBuildingContext buildingContext ) {
1123
+ private static Class <?> determineSemanticJavaType (MemberDetails property ) {
1130
1124
if ( property .isPlural () ) {
1131
1125
final ClassDetails collectionClassDetails = property .getType ().determineRawClass ();
1132
1126
final Class <?> collectionClass = collectionClassDetails .toJavaClass ();
@@ -1536,25 +1530,23 @@ private void handleFetch() {
1536
1530
1537
1531
private void setHibernateFetchMode (org .hibernate .annotations .FetchMode fetchMode ) {
1538
1532
switch ( fetchMode ) {
1539
- case JOIN -> {
1533
+ case JOIN :
1540
1534
collection .setFetchMode ( FetchMode .JOIN );
1541
1535
collection .setLazy ( false );
1542
- }
1543
- case SELECT -> {
1536
+ break ;
1537
+ case SELECT :
1544
1538
collection .setFetchMode ( FetchMode .SELECT );
1545
- }
1546
- case SUBSELECT -> {
1539
+ break ;
1540
+ case SUBSELECT :
1547
1541
collection .setFetchMode ( FetchMode .SELECT );
1548
1542
collection .setSubselectLoadable ( true );
1549
1543
collection .getOwner ().setSubselectLoadableCollections ( true );
1550
- }
1551
- default -> {
1544
+ break ;
1545
+ default :
1552
1546
throw new AssertionFailure ( "unknown fetch type" );
1553
- }
1554
1547
}
1555
1548
}
1556
1549
1557
- @ SuppressWarnings ("deprecation" )
1558
1550
private void handleLazy () {
1559
1551
final FetchType jpaFetchType = getJpaFetchType ();
1560
1552
collection .setLazy ( jpaFetchType == LAZY );
@@ -1877,7 +1869,6 @@ private String getWhereOnCollectionClause() {
1877
1869
}
1878
1870
1879
1871
private String getWhereOnClassClause () {
1880
- final TypeDetails elementType = property .getElementType ();
1881
1872
final SQLRestriction restrictionOnClass = getOverridableAnnotation (
1882
1873
property .getAssociatedType ().determineRawClass (),
1883
1874
SQLRestriction .class ,
@@ -2010,7 +2001,7 @@ private static String buildOrderById(PersistentClass associatedClass, String ord
2010
2001
public static String adjustUserSuppliedValueCollectionOrderingFragment (String orderByFragment ) {
2011
2002
if ( orderByFragment != null ) {
2012
2003
orderByFragment = orderByFragment .trim ();
2013
- if ( orderByFragment .length () == 0 || orderByFragment .equalsIgnoreCase ( "asc" ) ) {
2004
+ if ( orderByFragment .isEmpty () || orderByFragment .equalsIgnoreCase ( "asc" ) ) {
2014
2005
// This indicates something like either:
2015
2006
// `@OrderBy()`
2016
2007
// `@OrderBy("asc")
@@ -2071,7 +2062,6 @@ private DependantValue buildCollectionKey(AnnotatedJoinColumns joinColumns, OnDe
2071
2062
if ( key .getForeignKeyName () == null
2072
2063
&& key .getForeignKeyDefinition () == null
2073
2064
&& collectionTableAnn .joinColumns ().length == 1 ) {
2074
- //noinspection unchecked
2075
2065
final JoinColumn joinColumn = collectionTableAnn .joinColumns ()[0 ];
2076
2066
final ForeignKey nestedForeignKey = joinColumn .foreignKey ();
2077
2067
key .setForeignKeyName ( nullIfEmpty ( nestedForeignKey .name () ) );
@@ -2237,12 +2227,13 @@ private void handleElementCollection(TypeDetails elementType, String hqlOrderBy)
2237
2227
buildingContext
2238
2228
);
2239
2229
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 ;
2242
2233
holder .prepare ( property , isComposite );
2243
2234
2244
2235
if ( isComposite ) {
2245
- handleCompositeCollectionElement ( hqlOrderBy , elementType , elementClass , holder , compositeUserType );
2236
+ handleCompositeCollectionElement ( hqlOrderBy , elementType , holder , compositeUserType );
2246
2237
}
2247
2238
else {
2248
2239
handleCollectionElement ( elementType , hqlOrderBy , elementClass , holder );
@@ -2283,7 +2274,6 @@ private void handleCollectionElement(
2283
2274
private void handleCompositeCollectionElement (
2284
2275
String hqlOrderBy ,
2285
2276
TypeDetails elementType ,
2286
- ClassDetails elementClass ,
2287
2277
CollectionPropertyHolder holder ,
2288
2278
Class <? extends CompositeUserType <?>> compositeUserType ) {
2289
2279
//TODO be smart with isNullable
@@ -2555,7 +2545,7 @@ private static void addCheckToCollection(Table collectionTable, Check check) {
2555
2545
private void processSoftDeletes () {
2556
2546
assert collection .getCollectionTable () != null ;
2557
2547
2558
- final SoftDelete softDelete = extractSoftDelete ( property , propertyHolder , buildingContext );
2548
+ final SoftDelete softDelete = extractSoftDelete ( property , buildingContext );
2559
2549
if ( softDelete == null ) {
2560
2550
return ;
2561
2551
}
@@ -2568,20 +2558,18 @@ private void processSoftDeletes() {
2568
2558
);
2569
2559
}
2570
2560
2571
- private static SoftDelete extractSoftDelete (
2572
- MemberDetails property ,
2573
- PropertyHolder propertyHolder ,
2574
- MetadataBuildingContext context ) {
2561
+ private static SoftDelete extractSoftDelete (MemberDetails property , MetadataBuildingContext context ) {
2575
2562
final SoftDelete fromProperty = property .getDirectAnnotationUsage ( SoftDelete .class );
2576
2563
if ( fromProperty != null ) {
2577
2564
return fromProperty ;
2578
2565
}
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
+ }
2585
2573
}
2586
2574
2587
2575
private void handleUnownedManyToMany (
0 commit comments