I was doing a simple mater details delete with some code and no matter what I did the parent delete got called before the child, then I remembered post changes (this.getDBTransaction().postChanges();) and called it after deleting the children. And that is how postChanges saved my life.
Code for fun...
Key key = new Key(new Object[] { objectId });
Row[] rows = getParentVO().findByKey(key, 1);
if (rows != null && rows.length > 0) {
ParentVORowImpl parent = (ParentVORowImpl) rows[0];
RowIterator rowIterator = parent.getChildVO();
removeRows(rowIterator);
this.getDBTransaction().postChanges();
parent.remove();
this.getDBTransaction().commit();
}
public void removeRows(RowIterator rowIterator) {
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
row.remove();
}
}
Comments
Post a Comment