HHH-13453 Optimise CascadingActions for the most likely case

This commit is contained in:
Sanne Grinovero 2019-06-22 23:59:32 +01:00
parent 007ab2f479
commit a01929c5b8
1 changed files with 8 additions and 9 deletions

View File

@ -369,12 +369,11 @@ public class CascadingActions {
int propertyIndex) {
if ( propertyType.isEntityType() ) {
Object child = persister.getPropertyValue( parent, propertyIndex );
String childEntityName = ((EntityType) propertyType).getAssociatedEntityName( session.getFactory() );
if ( child != null
&& !isInManagedState( child, session )
&& !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
&& ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
&& !(child instanceof HibernateProxy) ) { //a proxy cannot be transient and it breaks ForeignKeys.isTransient
final String childEntityName = ((EntityType) propertyType).getAssociatedEntityName(session.getFactory());
if (ForeignKeys.isTransient(childEntityName, child, null, session)) {
String parentEntityName = persister.getEntityName();
String propertyName = persister.getPropertyNames()[propertyIndex];
throw new TransientPropertyValueException(
@ -383,7 +382,7 @@ public class CascadingActions {
parentEntityName,
propertyName
);
}
}
}
}