Distinguish between complex reference and multi-constraint.
Some initial code for unset-constraint in Node.unset() TODO: we need to make sure Relation.getDbField() returns the correct value for non-complex references!
This commit is contained in:
parent
25d2e65674
commit
25255ad5da
2 changed files with 25 additions and 5 deletions
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue