#1743 - When using @PrimaryKeyJoinColumn, FK constraint generation cannot be disabled

This commit is contained in:
rob bygrave committed 2019-07-01 00:07:14 +12:00
1 parent d49a7c415f
commit 9f19ed5376
5 files changed
+34 -17

No files matched your search

@@ -1654,8 +1654,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
String baseTable = prop.getDesc().getBaseTable();
DeployTableJoin inverse = prop.getTableJoin().createInverse(baseTable);
TableJoin inverseJoin = new TableJoin(inverse);
TableJoin inverseJoin = new TableJoin(inverse, prop.getForeignKey());
DeployBeanInfo<?> target = deployInfoMap.get(prop.getTargetType());
target.setPrimaryKeyJoin(inverseJoin);
}
@@ -45,6 +45,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
private final boolean orphanRemoval;
private final boolean primaryKeyExport;
private final boolean primaryKeyJoin;
private AssocOneHelp localHelp;
@@ -75,6 +76,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
super(descriptor, deploy);
primaryKeyExport = deploy.isPrimaryKeyExport();
primaryKeyJoin = deploy.isPrimaryKeyJoin();
oneToOne = deploy.isOneToOne();
oneToOneExported = deploy.isOneToOneExported();
orphanRemoval = deploy.isOrphanRemoval();
@@ -100,6 +102,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
public BeanPropertyAssocOne(BeanPropertyAssocOne source, BeanPropertyOverride override) {
super(source, override);
primaryKeyExport = source.primaryKeyExport;
primaryKeyJoin = source.primaryKeyJoin;
oneToOne = source.oneToOne;
oneToOneExported = source.oneToOneExported;
orphanRemoval = source.orphanRemoval;
@@ -357,7 +360,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
public boolean hasForeignKey() {
return foreignKey == null || !foreignKey.isNoConstraint();
return foreignKey == null || primaryKeyJoin || !foreignKey.isNoConstraint();
}
public boolean hasForeignKeyIndex() {
@@ -33,11 +33,17 @@ public final class TableJoin {
*/
private final int queryHash;
private final PropertyForeignKey foreignKey;
public TableJoin(DeployTableJoin deploy) {
this(deploy, null);
}
/**
* Create a TableJoin.
*/
public TableJoin(DeployTableJoin deploy) {
public TableJoin(DeployTableJoin deploy, PropertyForeignKey foreignKey) {
this.foreignKey = foreignKey;
this.table = InternString.intern(deploy.getTable());
this.type = deploy.getType();
this.inheritInfo = deploy.getInheritInfo();
@@ -52,6 +58,7 @@ public final class TableJoin {
}
private TableJoin(TableJoin source, String overrideColumn) {
this.foreignKey = null;
this.table = source.table;
this.type = source.type;
this.inheritInfo = source.inheritInfo;
@@ -96,14 +103,6 @@ public final class TableJoin {
return true;
}
/**
* Return a hash value for adding to a query plan.
*/
public int queryHash() {
return queryHash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(30);
@@ -114,6 +113,13 @@ public final class TableJoin {
return sb.toString();
}
/**
* Return the foreign key options.
*/
public PropertyForeignKey getForeignKey() {
return foreignKey;
}
/**
* Return the join columns.
*/