Skip to content

Commit

Permalink
HHH-13453 Optimise CascadingActions for the most likely case
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Jun 25, 2019
1 parent cf1b7c3 commit 2ea0505
Showing 1 changed file with 8 additions and 9 deletions.
Expand Up @@ -369,21 +369,20 @@ public void noCascade(
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 ) ) {
String parentEntityName = persister.getEntityName();
String propertyName = persister.getPropertyNames()[propertyIndex];
throw new TransientPropertyValueException(
&& !(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(
"object references an unsaved transient instance - save the transient instance before flushing",
childEntityName,
parentEntityName,
propertyName
);

);
}
}
}
}
Expand Down

0 comments on commit 2ea0505

Please sign in to comment.