Support @ManyToOne inside @Embeddables - fix for #52 (#1608)

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Initial test and work

* #52 - @ManyToOne support inside @Embeddables

Update test with sql capture

* #52 - @ManyToOne support inside @Embeddables

Update test with cache clearing before hand (such that we hit DB on lazy load)
This commit is contained in:
Rob Bygrave authored and GitHub committed 2019-01-10 03:40:02 +13:00
1 parent 2b0669c2ae
commit 6b27a9d280
20 files changed
+356 -69

No files matched your search

@@ -93,14 +93,35 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
}
/**
* Copy constructor for ManyToOne inside Embeddable.
*/
public BeanPropertyAssocOne(BeanPropertyAssocOne source, BeanPropertyOverride override) {
super(source, override);
primaryKeyExport = source.primaryKeyExport;
oneToOne = source.oneToOne;
oneToOneExported = source.oneToOneExported;
orphanRemoval = source.orphanRemoval;
embeddedProps = null;
embeddedPropsMap = null;
}
@Override
public void initialise(BeanDescriptorInitContext initContext) {
super.initialise(initContext);
initialiseAssocOne();
initialiseAssocOne(initContext.getEmbeddedPrefix());
if (embedded) {
// initialise ManyToOne importedId
initContext.setEmbeddedPrefix(name);
for (BeanProperty embeddedProp : embeddedProps) {
embeddedProp.initialise(initContext);
}
initContext.setEmbeddedPrefix(null);
}
}
private void initialiseAssocOne() {
localHelp = createHelp(embedded, oneToOneExported);
private void initialiseAssocOne(String embeddedPrefix) {
localHelp = createHelp(embedded, oneToOneExported, embeddedPrefix);
if (!isTransient) {
//noinspection StatementWithEmptyBody
@@ -668,7 +689,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
}
private AssocOneHelp createHelp(boolean embedded, boolean oneToOneExported) {
private AssocOneHelp createHelp(boolean embedded, boolean oneToOneExported, String embeddedPrefix) {
if (embedded) {
return new AssocOneHelpEmbedded(this);
} else if (oneToOneExported) {
@@ -677,7 +698,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
if (targetInheritInfo != null) {
return new AssocOneHelpRefInherit(this);
} else {
return new AssocOneHelpRefSimple(this);
return new AssocOneHelpRefSimple(this, embeddedPrefix);
}
}
}