65
65
import org .hibernate .sql .results .graph .collection .internal .DelayedCollectionFetch ;
66
66
import org .hibernate .sql .results .graph .collection .internal .EagerCollectionFetch ;
67
67
import org .hibernate .sql .results .graph .collection .internal .SelectEagerCollectionFetch ;
68
- import org .jboss .logging .Logger ;
69
68
70
69
import java .util .function .BiConsumer ;
71
70
import java .util .function .Consumer ;
80
79
public class PluralAttributeMappingImpl
81
80
extends AbstractAttributeMapping
82
81
implements PluralAttributeMapping , FetchProfileAffectee , FetchOptions {
83
- private static final Logger log = Logger .getLogger ( PluralAttributeMappingImpl .class );
84
82
85
83
/**
86
84
* Allows callback after creation of the attribute mapping.
@@ -96,8 +94,7 @@ public interface Aware {
96
94
void injectAttributeMapping (PluralAttributeMapping attributeMapping );
97
95
}
98
96
99
- @ SuppressWarnings ("rawtypes" )
100
- private final CollectionMappingType collectionMappingType ;
97
+ private final CollectionMappingType <?> collectionMappingType ;
101
98
private final String referencedPropertyName ;
102
99
private final String mapKeyPropertyName ;
103
100
@@ -237,10 +234,11 @@ public boolean isBidirectionalAttributeName(NavigablePath fetchablePath, ToOneAt
237
234
return fetchablePath .getLocalName ().endsWith ( bidirectionalAttributeName );
238
235
}
239
236
240
- @ SuppressWarnings ("unused" )
241
237
public void finishInitialization (
238
+ @ SuppressWarnings ("unused" )
242
239
Property bootProperty ,
243
240
Collection bootDescriptor ,
241
+ @ SuppressWarnings ("unused" )
244
242
MappingModelCreationProcess creationProcess ) {
245
243
final boolean hasOrder = bootDescriptor .getOrderBy () != null ;
246
244
final boolean hasManyToManyOrder = bootDescriptor .getManyToManyOrdering () != null ;
@@ -249,13 +247,6 @@ public void finishInitialization(
249
247
final TranslationContext context = collectionDescriptor ::getFactory ;
250
248
251
249
if ( hasOrder ) {
252
- if ( log .isTraceEnabled () ) {
253
- log .tracef (
254
- "Translating order-by fragment [%s] for collection role: %s" ,
255
- bootDescriptor .getOrderBy (),
256
- collectionDescriptor .getRole ()
257
- );
258
- }
259
250
orderByFragment = OrderByFragmentTranslator .translate (
260
251
bootDescriptor .getOrderBy (),
261
252
this ,
@@ -264,13 +255,6 @@ public void finishInitialization(
264
255
}
265
256
266
257
if ( hasManyToManyOrder ) {
267
- if ( log .isTraceEnabled () ) {
268
- log .tracef (
269
- "Translating many-to-many order-by fragment [%s] for collection role: %s" ,
270
- bootDescriptor .getOrderBy (),
271
- collectionDescriptor .getRole ()
272
- );
273
- }
274
258
manyToManyOrderByFragment = OrderByFragmentTranslator .translate (
275
259
bootDescriptor .getManyToManyOrdering (),
276
260
this ,
@@ -286,8 +270,7 @@ public NavigableRole getNavigableRole() {
286
270
}
287
271
288
272
@ Override
289
- @ SuppressWarnings ("rawtypes" )
290
- public CollectionMappingType getMappedType () {
273
+ public CollectionMappingType <?> getMappedType () {
291
274
return collectionMappingType ;
292
275
}
293
276
@@ -384,32 +367,34 @@ public boolean hasPartitionedSelectionMapping() {
384
367
385
368
@ Override
386
369
public void applySoftDeleteRestrictions (TableGroup tableGroup , PredicateConsumer predicateConsumer ) {
387
- if ( !hasSoftDelete () ) {
388
- // short-circuit
389
- return ;
390
- }
370
+ if ( hasSoftDelete () ) {
371
+ final var descriptor = getCollectionDescriptor ();
372
+ if ( descriptor .isOneToMany () || descriptor .isManyToMany () ) {
373
+ // see if the associated entity has soft-delete defined
374
+ final var elementDescriptor = (EntityCollectionPart ) getElementDescriptor ();
375
+ final var associatedEntityDescriptor = elementDescriptor .getAssociatedEntityMappingType ();
376
+ final var softDeleteMapping = associatedEntityDescriptor .getSoftDeleteMapping ();
377
+ if ( softDeleteMapping != null ) {
378
+ final String primaryTableName =
379
+ associatedEntityDescriptor .getSoftDeleteTableDetails ().getTableName ();
380
+ final TableReference primaryTableReference =
381
+ tableGroup .resolveTableReference ( primaryTableName );
382
+ final Predicate softDeleteRestriction =
383
+ softDeleteMapping .createNonDeletedRestriction ( primaryTableReference );
384
+ predicateConsumer .applyPredicate ( softDeleteRestriction );
385
+ }
386
+ }
391
387
392
- if ( getCollectionDescriptor ().isOneToMany ()
393
- || getCollectionDescriptor ().isManyToMany () ) {
394
- // see if the associated entity has soft-delete defined
395
- final EntityCollectionPart elementDescriptor = (EntityCollectionPart ) getElementDescriptor ();
396
- final EntityMappingType associatedEntityDescriptor = elementDescriptor .getAssociatedEntityMappingType ();
397
- final SoftDeleteMapping softDeleteMapping = associatedEntityDescriptor .getSoftDeleteMapping ();
388
+ // apply the collection's soft-delete mapping, if one
389
+ final var softDeleteMapping = getSoftDeleteMapping ();
398
390
if ( softDeleteMapping != null ) {
399
- final String primaryTableName = associatedEntityDescriptor .getSoftDeleteTableDetails ().getTableName ();
400
- final TableReference primaryTableReference = tableGroup .resolveTableReference ( primaryTableName );
401
- final Predicate softDeleteRestriction = softDeleteMapping .createNonDeletedRestriction ( primaryTableReference );
391
+ final TableReference primaryTableReference =
392
+ tableGroup .resolveTableReference ( getSoftDeleteTableDetails ().getTableName () );
393
+ final Predicate softDeleteRestriction =
394
+ softDeleteMapping .createNonDeletedRestriction ( primaryTableReference );
402
395
predicateConsumer .applyPredicate ( softDeleteRestriction );
403
396
}
404
397
}
405
-
406
- // apply the collection's soft-delete mapping, if one
407
- final SoftDeleteMapping softDeleteMapping = getSoftDeleteMapping ();
408
- if ( softDeleteMapping != null ) {
409
- final TableReference primaryTableReference = tableGroup .resolveTableReference ( getSoftDeleteTableDetails ().getTableName () );
410
- final Predicate softDeleteRestriction = softDeleteMapping .createNonDeletedRestriction ( primaryTableReference );
411
- predicateConsumer .applyPredicate ( softDeleteRestriction );
412
- }
413
398
}
414
399
415
400
@ Override
@@ -418,9 +403,9 @@ public <T> DomainResult<T> createDomainResult(
418
403
TableGroup tableGroup ,
419
404
String resultVariable ,
420
405
DomainResultCreationState creationState ) {
421
- final TableGroup collectionTableGroup = creationState . getSqlAstCreationState ()
422
- .getFromClauseAccess ()
423
- .getTableGroup ( navigablePath );
406
+ final TableGroup collectionTableGroup =
407
+ creationState . getSqlAstCreationState () .getFromClauseAccess ()
408
+ .getTableGroup ( navigablePath );
424
409
425
410
assert collectionTableGroup != null ;
426
411
@@ -440,7 +425,7 @@ public Fetch generateFetch(
440
425
boolean selected ,
441
426
String resultVariable ,
442
427
DomainResultCreationState creationState ) {
443
- final SqlAstCreationState sqlAstCreationState = creationState .getSqlAstCreationState ();
428
+ final var sqlAstCreationState = creationState .getSqlAstCreationState ();
444
429
445
430
final boolean added = creationState .registerVisitedAssociationKey ( fkDescriptor .getAssociationKey () );
446
431
0 commit comments