mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: possible NPE in DeleteUnloadedForeignKeys.deleteCascade and in initPostTarget (#1601)
This commit is contained in:
committed by
Rob Bygrave
parent
50de32af29
commit
b18bc82b8a
@@ -204,7 +204,9 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
||||
public void initialisePostTarget() {
|
||||
if (childMasterProperty != null) {
|
||||
BeanProperty masterId = childMasterProperty.getTargetDescriptor().getIdProperty();
|
||||
childMasterIdProperty = childMasterProperty.getName() + "." + masterId.getName();
|
||||
if (masterId != null) { // in docstore only, the master-id may be not available
|
||||
childMasterIdProperty = childMasterProperty.getName() + "." + masterId.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,15 +84,17 @@ class DeleteUnloadedForeignKeys {
|
||||
*/
|
||||
void deleteCascade() {
|
||||
|
||||
for (BeanPropertyAssocOne<?> prop : propList) {
|
||||
Object detailBean = prop.getValue(beanWithForeignKeys);
|
||||
if (beanWithForeignKeys != null) {
|
||||
for (BeanPropertyAssocOne<?> prop : propList) {
|
||||
Object detailBean = prop.getValue(beanWithForeignKeys);
|
||||
|
||||
// if bean exists with a unique id then delete it
|
||||
if (detailBean != null && prop.hasId((EntityBean) detailBean)) {
|
||||
if (deletePermanent) {
|
||||
server.deletePermanent(detailBean, request.getTransaction());
|
||||
} else {
|
||||
server.delete(detailBean, request.getTransaction());
|
||||
// if bean exists with a unique id then delete it
|
||||
if (detailBean != null && prop.hasId((EntityBean) detailBean)) {
|
||||
if (deletePermanent) {
|
||||
server.deletePermanent(detailBean, request.getTransaction());
|
||||
} else {
|
||||
server.delete(detailBean, request.getTransaction());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user