HHH-13453 Optimise CascadingActions for the most likely case
This commit is contained in:
parent
007ab2f479
commit
a01929c5b8
|
@ -369,21 +369,20 @@ public class CascadingActions {
|
||||||
int propertyIndex) {
|
int propertyIndex) {
|
||||||
if ( propertyType.isEntityType() ) {
|
if ( propertyType.isEntityType() ) {
|
||||||
Object child = persister.getPropertyValue( parent, propertyIndex );
|
Object child = persister.getPropertyValue( parent, propertyIndex );
|
||||||
String childEntityName = ((EntityType) propertyType).getAssociatedEntityName( session.getFactory() );
|
|
||||||
|
|
||||||
if ( child != null
|
if ( child != null
|
||||||
&& !isInManagedState( child, session )
|
&& !isInManagedState( child, session )
|
||||||
&& !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
|
&& !(child instanceof HibernateProxy) ) { //a proxy cannot be transient and it breaks ForeignKeys.isTransient
|
||||||
&& ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
|
final String childEntityName = ((EntityType) propertyType).getAssociatedEntityName(session.getFactory());
|
||||||
String parentEntityName = persister.getEntityName();
|
if (ForeignKeys.isTransient(childEntityName, child, null, session)) {
|
||||||
String propertyName = persister.getPropertyNames()[propertyIndex];
|
String parentEntityName = persister.getEntityName();
|
||||||
throw new TransientPropertyValueException(
|
String propertyName = persister.getPropertyNames()[propertyIndex];
|
||||||
|
throw new TransientPropertyValueException(
|
||||||
"object references an unsaved transient instance - save the transient instance before flushing",
|
"object references an unsaved transient instance - save the transient instance before flushing",
|
||||||
childEntityName,
|
childEntityName,
|
||||||
parentEntityName,
|
parentEntityName,
|
||||||
propertyName
|
propertyName
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue