#994 - @OneToOne cacade does not honor orphanRemoval = true

This commit is contained in:
Rob Bygrave
2018-02-20 16:59:55 +13:00
parent 81d48d67a7
commit 3e8b06e38e
8 changed files with 229 additions and 1 deletions
@@ -37,6 +37,8 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
private final boolean oneToOneExported;
private final boolean orphanRemoval;
private final boolean importedPrimaryKey;
private final boolean primaryKeyExport;
@@ -76,6 +78,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
importedPrimaryKey = deploy.isImportedPrimaryKey();
oneToOne = deploy.isOneToOne();
oneToOneExported = deploy.isOneToOneExported();
orphanRemoval = deploy.isOrphanRemoval();
if (embedded) {
// Overriding of the columns and use table alias of owning BeanDescriptor
@@ -338,6 +341,10 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
return oneToOneExported;
}
public boolean isOrphanRemoval() {
return orphanRemoval;
}
/**
* If true this bean maps to the primary key.
*/
@@ -25,6 +25,8 @@ public class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
private PropertyForeignKey foreignKey;
private boolean orphanRemoval;
/**
* Create the property.
*/
@@ -160,4 +162,12 @@ public class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
public PropertyForeignKey getForeignKey() {
return foreignKey;
}
public void setOrphanRemoval(boolean orphanRemoval) {
this.orphanRemoval = orphanRemoval;
}
public boolean isOrphanRemoval() {
return orphanRemoval;
}
}
@@ -216,6 +216,7 @@ public class AnnotationAssocOnes extends AnnotationParser {
prop.setMappedBy(propAnn.mappedBy());
if (!"".equals(propAnn.mappedBy())) {
prop.setOneToOneExported();
prop.setOrphanRemoval(propAnn.orphanRemoval());
}
setCascadeTypes(propAnn.cascade(), prop.getCascadeInfo());