#1748 - Support older JPA API that doesn't have orphanRemoval() or joinColumn.foreignKey()

This commit is contained in:
rob bygrave
2019-07-03 00:08:50 +12:00
parent e62db11f01
commit 2a8fad7364
2 changed files with 27 additions and 8 deletions
@@ -69,12 +69,21 @@ class AnnotationAssocManys extends AnnotationParser {
}
}
private boolean readOrphanRemoval(OneToMany property) {
try {
return property.orphanRemoval();
} catch (NoSuchMethodError e) {
// Support old JPA API
return false;
}
}
private void read(DeployBeanPropertyAssocMany<?> prop) {
OneToMany oneToMany = get(prop, OneToMany.class);
if (oneToMany != null) {
readToOne(oneToMany, prop);
if (oneToMany.orphanRemoval()) {
if (readOrphanRemoval(oneToMany)) {
prop.setModifyListenMode(ModifyListenMode.REMOVALS);
prop.getCascadeInfo().setDelete(true);
}