if (crel != null) {
if (cnst.localKeyIsPrimary(home.getDbMapping())) {
// only set node if property in child object is defined as reference.
if (crel.reftype == REFERENCE) {
INode currentValue = child.getNode(crel.propName);
// we set the backwards reference iff the reference is currently unset, if
// is set to a transient object, or if the new target is not transient. This
// prevents us from overwriting a persistent refererence with a transient one,
// which would most probably not be what we want.
if ((currentValue == null) ||
((currentValue != home) &&
((currentValue.getState() == Node.TRANSIENT) ||
(home.getState() != Node.TRANSIENT)))) try {
child.setNode(crel.propName, home);
} catch (Exception ignore) {
// in some cases, getNonVirtualParent() doesn't work
// correctly for transient nodes, so this may fail.