19
19
import org .hibernate .engine .spi .CollectionEntry ;
20
20
import org .hibernate .engine .spi .EntityEntry ;
21
21
import org .hibernate .engine .spi .PersistenceContext ;
22
+ import org .hibernate .engine .spi .SessionFactoryImplementor ;
22
23
import org .hibernate .engine .spi .Status ;
23
24
import org .hibernate .event .spi .DeleteContext ;
24
25
import org .hibernate .event .spi .EventSource ;
25
26
import org .hibernate .internal .CoreLogging ;
26
27
import org .hibernate .internal .CoreMessageLogger ;
27
- import org .hibernate .metamodel .mapping .AttributeMapping ;
28
- import org .hibernate .metamodel .mapping .AttributeMappingsList ;
29
- import org .hibernate .metamodel .mapping .PluralAttributeMapping ;
30
28
import org .hibernate .persister .collection .CollectionPersister ;
31
29
import org .hibernate .persister .entity .EntityPersister ;
32
30
import org .hibernate .type .AssociationType ;
@@ -172,7 +170,6 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
172
170
type ,
173
171
style ,
174
172
propertyName ,
175
- persister .getAttributeMapping ( i ),
176
173
anything ,
177
174
false
178
175
);
@@ -214,17 +211,16 @@ private static <T> void cascadeProperty(
214
211
final Type type ,
215
212
final CascadeStyle style ,
216
213
final String propertyName ,
217
- final AttributeMapping attributeMapping ,
218
214
final T anything ,
219
215
final boolean isCascadeDeleteEnabled ) throws HibernateException {
220
216
221
217
if ( child != null ) {
222
218
if ( type .isAssociationType () ) {
223
219
final AssociationType associationType = (AssociationType ) type ;
224
- final boolean strictUnowned = eventSource .getSessionFactory ()
220
+ final boolean unownedTransient = eventSource .getSessionFactory ()
225
221
.getSessionFactoryOptions ()
226
222
.isUnownedAssociationTransientCheck ();
227
- if ( cascadeAssociationNow ( action , cascadePoint , associationType , attributeMapping , strictUnowned ) ) {
223
+ if ( cascadeAssociationNow ( action , cascadePoint , associationType , eventSource . getFactory (), unownedTransient ) ) {
228
224
cascadeAssociation (
229
225
action ,
230
226
cascadePoint ,
@@ -254,7 +250,6 @@ else if ( type.isComponentType() ) {
254
250
parent ,
255
251
child ,
256
252
(CompositeType ) type ,
257
- attributeMapping ,
258
253
anything
259
254
);
260
255
if ( componentPath != null ) {
@@ -390,14 +385,14 @@ private static boolean cascadeAssociationNow(
390
385
CascadingAction <?> action ,
391
386
CascadePoint cascadePoint ,
392
387
AssociationType associationType ,
393
- AttributeMapping attributeMapping ,
394
- boolean isStrictUnownedTransienceEnabled ) {
388
+ SessionFactoryImplementor factory ,
389
+ boolean unownedTransient ) {
395
390
return associationType .getForeignKeyDirection ().cascadeNow ( cascadePoint )
396
- // For check on flush, we should only check owned associations when strictness is enforced
397
- && ( action != CHECK_ON_FLUSH || isStrictUnownedTransienceEnabled || !isUnownedAssociation ( associationType , attributeMapping ) );
391
+ // For check on flush, we should only check unowned associations when strictness is enforced
392
+ && ( action != CHECK_ON_FLUSH || unownedTransient || !isUnownedAssociation ( associationType , factory ) );
398
393
}
399
394
400
- private static boolean isUnownedAssociation (AssociationType associationType , AttributeMapping attributeMapping ) {
395
+ private static boolean isUnownedAssociation (AssociationType associationType , SessionFactoryImplementor factory ) {
401
396
if ( associationType .isEntityType () ) {
402
397
if ( associationType instanceof ManyToOneType ) {
403
398
final ManyToOneType manyToOne = (ManyToOneType ) associationType ;
@@ -412,7 +407,7 @@ else if ( associationType instanceof OneToOneType ) {
412
407
}
413
408
else if ( associationType .isCollectionType () ) {
414
409
// for collections, we can ask the persister if we're on the inverse side
415
- return ( (PluralAttributeMapping ) attributeMapping ).getCollectionDescriptor (). isInverse ();
410
+ return ( (CollectionType ) associationType ).isInverse ( factory );
416
411
}
417
412
return false ;
418
413
}
@@ -425,14 +420,10 @@ private static <T> void cascadeComponent(
425
420
final Object parent ,
426
421
final Object child ,
427
422
final CompositeType componentType ,
428
- final AttributeMapping attributeMapping ,
429
423
final T anything ) {
430
424
Object [] children = null ;
431
425
final Type [] types = componentType .getSubtypes ();
432
426
final String [] propertyNames = componentType .getPropertyNames ();
433
- final AttributeMappingsList subMappings = attributeMapping != null ?
434
- attributeMapping .asEmbeddedAttributeMapping ().getEmbeddableTypeDescriptor ().getAttributeMappings () :
435
- null ;
436
427
for ( int i = 0 ; i < types .length ; i ++ ) {
437
428
final CascadeStyle componentPropertyStyle = componentType .getCascadeStyle ( i );
438
429
final String subPropertyName = propertyNames [i ];
@@ -452,7 +443,6 @@ private static <T> void cascadeComponent(
452
443
types [i ],
453
444
componentPropertyStyle ,
454
445
subPropertyName ,
455
- subMappings != null && i < subMappings .size () ? subMappings .get ( i ) : null ,
456
446
anything ,
457
447
false
458
448
);
@@ -594,7 +584,6 @@ private static <T> void cascadeCollectionElements(
594
584
elemType ,
595
585
style ,
596
586
collectionType .getRole ().substring ( collectionType .getRole ().lastIndexOf ('.' ) + 1 ),
597
- null ,
598
587
anything ,
599
588
isCascadeDeleteEnabled
600
589
);
0 commit comments