@@ -162,6 +162,7 @@ else if ( action.performOnLazyProperty() && type instanceof EntityType ) {
162
162
action ,
163
163
cascadePoint ,
164
164
eventSource ,
165
+ persister .getEntityName (),
165
166
null ,
166
167
parent ,
167
168
child ,
@@ -203,6 +204,7 @@ private static <T> void cascadeProperty(
203
204
final CascadingAction <T > action ,
204
205
final CascadePoint cascadePoint ,
205
206
final EventSource eventSource ,
207
+ final String entityName ,
206
208
List <String > componentPath ,
207
209
final Object parent ,
208
210
final Object child ,
@@ -219,6 +221,8 @@ private static <T> void cascadeProperty(
219
221
action ,
220
222
cascadePoint ,
221
223
eventSource ,
224
+ entityName ,
225
+ propertyName ,
222
226
componentPath ,
223
227
parent ,
224
228
child ,
@@ -240,6 +244,7 @@ else if ( type instanceof ComponentType componentType ) {
240
244
action ,
241
245
cascadePoint ,
242
246
eventSource ,
247
+ entityName ,
243
248
componentPath ,
244
249
parent ,
245
250
child ,
@@ -385,6 +390,7 @@ private static <T> void cascadeComponent(
385
390
final CascadingAction <T > action ,
386
391
final CascadePoint cascadePoint ,
387
392
final EventSource eventSource ,
393
+ final String entityName ,
388
394
final List <String > componentPath ,
389
395
final Object parent ,
390
396
final Object child ,
@@ -398,7 +404,7 @@ private static <T> void cascadeComponent(
398
404
final String subPropertyName = propertyNames [i ];
399
405
final Type subPropertyType = types [i ];
400
406
if ( action .appliesTo ( subPropertyType , componentPropertyStyle )
401
- || componentPropertyStyle .hasOrphanDelete () && action .deleteOrphans () ) {
407
+ || componentPropertyStyle .hasOrphanDelete () && action .deleteOrphans () ) {
402
408
if ( children == null ) {
403
409
// Get children on demand.
404
410
children = componentType .getPropertyValues ( child , eventSource );
@@ -407,6 +413,7 @@ private static <T> void cascadeComponent(
407
413
action ,
408
414
cascadePoint ,
409
415
eventSource ,
416
+ entityName ,
410
417
componentPath ,
411
418
parent ,
412
419
children [i ],
@@ -424,6 +431,8 @@ private static <T> void cascadeAssociation(
424
431
final CascadingAction <T > action ,
425
432
final CascadePoint cascadePoint ,
426
433
final EventSource eventSource ,
434
+ final String entityName ,
435
+ final String propertyName ,
427
436
final List <String > componentPath ,
428
437
final Object parent ,
429
438
final Object child ,
@@ -432,13 +441,27 @@ private static <T> void cascadeAssociation(
432
441
final T anything ,
433
442
final boolean isCascadeDeleteEnabled ) {
434
443
if ( type instanceof EntityType || type instanceof AnyType ) {
435
- cascadeToOne ( action , eventSource , parent , child , type , style , anything , isCascadeDeleteEnabled );
444
+ cascadeToOne (
445
+ action ,
446
+ eventSource ,
447
+ parent ,
448
+ child ,
449
+ type ,
450
+ style ,
451
+ anything ,
452
+ isCascadeDeleteEnabled ,
453
+ entityName ,
454
+ propertyName ,
455
+ componentPath
456
+ );
436
457
}
437
458
else if ( type instanceof CollectionType collectionType ) {
438
459
cascadeCollection (
439
460
action ,
440
461
cascadePoint ,
441
462
eventSource ,
463
+ entityName ,
464
+ propertyName ,
442
465
componentPath ,
443
466
parent ,
444
467
child ,
@@ -456,6 +479,8 @@ private static <T> void cascadeCollection(
456
479
final CascadingAction <T > action ,
457
480
final CascadePoint cascadePoint ,
458
481
final EventSource eventSource ,
482
+ final String entityName ,
483
+ final String propertyName ,
459
484
final List <String > componentPath ,
460
485
final Object parent ,
461
486
final Object child ,
@@ -474,6 +499,8 @@ private static <T> void cascadeCollection(
474
499
? CascadePoint .AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION
475
500
: cascadePoint ,
476
501
eventSource ,
502
+ entityName ,
503
+ propertyName ,
477
504
componentPath ,
478
505
parent ,
479
506
child ,
@@ -497,17 +524,27 @@ private static <T> void cascadeToOne(
497
524
final Type type ,
498
525
final CascadeStyle style ,
499
526
final T anything ,
500
- final boolean isCascadeDeleteEnabled ) {
501
- final String entityName =
502
- type instanceof EntityType entityType
503
- ? entityType .getAssociatedEntityName ()
504
- : null ;
527
+ final boolean isCascadeDeleteEnabled ,
528
+ final String parentEntityName ,
529
+ final String propertyName ,
530
+ final List <String > componentPath ) {
505
531
if ( style .reallyDoCascade ( action ) ) {
506
532
//not really necessary, but good for consistency...
507
533
final PersistenceContext persistenceContext = eventSource .getPersistenceContextInternal ();
508
534
persistenceContext .addChildParent ( child , parent );
509
535
try {
510
- action .cascade ( eventSource , child , entityName , anything , isCascadeDeleteEnabled );
536
+ action .cascade (
537
+ eventSource ,
538
+ child ,
539
+ type instanceof EntityType entityType
540
+ ? entityType .getAssociatedEntityName ()
541
+ : null ,
542
+ parentEntityName ,
543
+ propertyName ,
544
+ componentPath ,
545
+ anything ,
546
+ isCascadeDeleteEnabled
547
+ );
511
548
}
512
549
finally {
513
550
persistenceContext .removeChildParent ( child );
@@ -522,6 +559,8 @@ private static <T> void cascadeCollectionElements(
522
559
final CascadingAction <T > action ,
523
560
final CascadePoint cascadePoint ,
524
561
final EventSource eventSource ,
562
+ final String entityName ,
563
+ final String propertyName ,
525
564
final List <String > componentPath ,
526
565
final Object parent ,
527
566
final Object child ,
@@ -546,12 +585,14 @@ private static <T> void cascadeCollectionElements(
546
585
action ,
547
586
cascadePoint ,
548
587
eventSource ,
588
+ entityName ,
549
589
componentPath ,
550
590
parent ,
551
591
iterator .next (),
552
592
elemType ,
553
593
style ,
554
- collectionType .getRole ().substring ( collectionType .getRole ().lastIndexOf ('.' ) + 1 ),
594
+ propertyName ,
595
+ // collectionType.getRole().substring( collectionType.getRole().lastIndexOf('.') + 1 ),
555
596
anything ,
556
597
isCascadeDeleteEnabled
557
598
);
@@ -583,8 +624,8 @@ private static <T> void cascadeCollectionElements(
583
624
// we can do the cast since orphan-delete does not apply to:
584
625
// 1. newly instantiated collections
585
626
// 2. arrays (we can't track orphans for detached arrays)
586
- final String entityName = collectionType .getAssociatedEntityName ( eventSource .getFactory () );
587
- deleteOrphans ( eventSource , entityName , persistentCollection );
627
+ final String elementEntityName = collectionType .getAssociatedEntityName ( eventSource .getFactory () );
628
+ deleteOrphans ( eventSource , elementEntityName , persistentCollection );
588
629
589
630
if ( traceEnabled ) {
590
631
LOG .tracev ( "Done deleting orphans for collection: {0}" , collectionType .getRole () );
0 commit comments