diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index e60d90ec..a7dff481 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -2369,11 +2369,13 @@ public final class Node implements INode, Serializable { Relation rel = (dbmap == null) ? null : dbmap.getPropertyRelation(propname); - if (rel != null && rel.isComplexReference()) { + if (rel != null && (rel.countConstraints() > 1 || rel.isComplexReference())) { rel.setConstraints(this, n); - Key key = new MultiKey(n.getDbMapping(), rel.getKeyParts(this)); - nmgr.nmgr.registerNode(n, key); - return; + if (rel.isComplexReference()) { + Key key = new MultiKey(n.getDbMapping(), rel.getKeyParts(this)); + nmgr.nmgr.registerNode(n, key); + return; + } } Property prop = (propMap == null) ? null : (Property) propMap.get(p2); @@ -2485,6 +2487,15 @@ public final class Node implements INode, Serializable { if (state == CLEAN) { markAs(MODIFIED); } + } else if (dbmap != null) { + // check if this is a complex constraint and we have to + // unset constraints. + Relation rel = dbmap.getExactPropertyRelation(propname); + + if (rel != null && (rel.isComplexReference() || rel.countConstraints() > 1)) { + p = getProperty(propname); + System.err.println ("NEED TO UNSET: "+p.getNodeValue()); + } } } catch (Exception ignore) { } diff --git a/src/helma/objectmodel/db/Relation.java b/src/helma/objectmodel/db/Relation.java index f02d4c66..6bbda01b 100644 --- a/src/helma/objectmodel/db/Relation.java +++ b/src/helma/objectmodel/db/Relation.java @@ -176,7 +176,7 @@ public final class Relation { // check if this is a non-trivial reference if (reftype == REFERENCE) { - if (constraints.length > 1 || !usesPrimaryKey()) { + if (constraints.length > 0 && !usesPrimaryKey()) { reftype = COMPLEX_REFERENCE; } } @@ -323,6 +323,15 @@ public final class Relation { return isPrivate; } + /** + * Returns the number of constraints for this relation. + */ + public int countConstraints() { + if (constraints == null) + return 0; + return constraints.length; + } + /** * Returns true if the object represented by this Relation has to be * created dynamically by the Helma objectmodel runtime as a virtual