HHH-4726 - Add support for delete-orphan cascading to <one-to-one/>

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18569 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-01-16 21:04:34 +00:00
parent 29152a8390
commit f163e9fd94
1 changed files with 12 additions and 1 deletions

View File

@ -1621,7 +1621,9 @@ public final class HbmBinder {
String cascade = node.attributeValue( "cascade" ); String cascade = node.attributeValue( "cascade" );
if ( cascade != null && cascade.indexOf( "delete-orphan" ) >= 0 ) { if ( cascade != null && cascade.indexOf( "delete-orphan" ) >= 0 ) {
if ( !manyToOne.isLogicalOneToOne() ) { if ( !manyToOne.isLogicalOneToOne() ) {
throw new MappingException( "many-to-one attributes do not support orphan delete: " + path ); throw new MappingException(
"many-to-one attribute [" + path + "] does not support orphan delete as it is not unique"
);
} }
} }
} }
@ -1688,6 +1690,15 @@ public final class HbmBinder {
oneToOne.setPropertyName( node.attributeValue( "name" ) ); oneToOne.setPropertyName( node.attributeValue( "name" ) );
oneToOne.setReferencedEntityName( getEntityName( node, mappings ) ); oneToOne.setReferencedEntityName( getEntityName( node, mappings ) );
String cascade = node.attributeValue( "cascade" );
if ( cascade != null && cascade.indexOf( "delete-orphan" ) >= 0 ) {
if ( oneToOne.isConstrained() ) {
throw new MappingException(
"one-to-one attribute [" + path + "] does not support orphan delete as it is constrained"
);
}
}
} }
public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings) public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings)