#1895 - Ebean creates invalid sql for particular @ManyToOne

This commit is contained in:
rob bygrave
2020-01-10 23:32:58 +13:00
parent 57cfd25eb5
commit 1e266a1532
6 changed files with 148 additions and 0 deletions
@@ -951,6 +951,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
}
if (matchSet.size() == 1) {
// all right with the world
prop.clearTableJoin();
return true;
}
if (matchSet.size() == 2) {
@@ -269,5 +269,12 @@ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> {
public <A> BeanDescriptor<A> getElementDescriptor() {
return (BeanDescriptor<A>)elementDescriptor;
}
/**
* Clear the table join due to an implied mappedBy.
*/
public void clearTableJoin() {
tableJoin.clear();
}
}
@@ -178,4 +178,16 @@ public class DeployTableJoin {
columns.get(0).setLocalDbColumn(dbColumn);
}
}
/**
* Clear the join columns due to an implied mappedBy.
* <p>
* Effectively prior to clear this was considered a unidirectional OneToMany and the
* foreign key was defined by naming convention. Clearing this means that it uses the
* foreign key as defined by the implied mappedBy property (the only ManyToOne that
* maps back to the parent (that holds the OneToMany).
*/
public void clear() {
columns.clear();
}
}