Did some fixes in setConstraint() which now checks if the backward
mapping is a primitive mapping or an object reference. Also allow the method to be called for group-by collections, which is why the new code should be regarded as experimental. Removed some dead code.
This commit is contained in:
parent
d269727524
commit
1cd27f8c1d
1 changed files with 15 additions and 33 deletions
|
@ -153,10 +153,6 @@ public class Relation {
|
||||||
|
|
||||||
constraints = new Constraint[cnst.size()];
|
constraints = new Constraint[cnst.size()];
|
||||||
cnst.copyInto (constraints);
|
cnst.copyInto (constraints);
|
||||||
|
|
||||||
// System.err.println ("PARSED RELATION "+this);
|
|
||||||
// if (accessor != null)
|
|
||||||
// System.err.println ("SET ACCESSOR: "+accessor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,25 +397,6 @@ public class Relation {
|
||||||
cnst.addElement (new Constraint (local, otherType.getTableName (), foreign, false));
|
cnst.addElement (new Constraint (local, otherType.getTableName (), foreign, false));
|
||||||
columnName = local;
|
columnName = local;
|
||||||
}
|
}
|
||||||
/* if ("_properties".equalsIgnoreCase (propName) || virtual) {
|
|
||||||
String subnodes2props = props.getProperty (propName+".aresubnodes");
|
|
||||||
subnodesAreProperties = "true".equalsIgnoreCase (subnodes2props);
|
|
||||||
if (virtual) {
|
|
||||||
String subnodefilter = props.getProperty (propName+".subnoderelation");
|
|
||||||
if (subnodefilter != null) {
|
|
||||||
Constraint c = null; // parseConstraint_v1 (subnodefilter);
|
|
||||||
if (c != null) {
|
|
||||||
cnst.add (c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// update virtual mapping, if it already exists
|
|
||||||
if (virtualMapping != null) {
|
|
||||||
virtualMapping.subnodesRel = getVirtualSubnodeRelation ();
|
|
||||||
virtualMapping.propertiesRel = getVirtualPropertyRelation ();
|
|
||||||
virtualMapping.lastTypeChange = ownType.lastTypeChange;
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -674,13 +651,15 @@ public class Relation {
|
||||||
for (int i=0; i<constraints.length; i++) {
|
for (int i=0; i<constraints.length; i++) {
|
||||||
// don't set groupby constraints since we don't know if the
|
// don't set groupby constraints since we don't know if the
|
||||||
// parent node is the base node or a group node
|
// parent node is the base node or a group node
|
||||||
if (constraints[i].isGroupby)
|
// if (constraints[i].isGroupby)
|
||||||
continue;
|
// continue;
|
||||||
Relation crel = otherType.columnNameToRelation (constraints[i].foreignName);
|
Relation crel = otherType.columnNameToRelation (constraints[i].foreignName);
|
||||||
if (crel != null) {
|
if (crel != null) {
|
||||||
// INode home = constraints[i].isGroupby ? parent : nonVirtual;
|
// INode home = constraints[i].isGroupby ? parent : nonVirtual;
|
||||||
String localName = constraints[i].localName;
|
String localName = constraints[i].localName;
|
||||||
if (localName == null || localName.equalsIgnoreCase (ownType.getIDField ())) {
|
if (localName == null || localName.equalsIgnoreCase (ownType.getIDField ())) {
|
||||||
|
// only set node if property in child object is defined as reference.
|
||||||
|
if (crel.reftype == REFERENCE) {
|
||||||
INode currentValue = child.getNode (crel.propName, false);
|
INode currentValue = child.getNode (crel.propName, false);
|
||||||
// we set the backwards reference iff the reference is currently unset, if
|
// 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
|
// is set to a transient object, or if the new target is not transient. This
|
||||||
|
@ -691,7 +670,10 @@ public class Relation {
|
||||||
(currentValue.getState() == Node.TRANSIENT ||
|
(currentValue.getState() == Node.TRANSIENT ||
|
||||||
home.getState() != Node.TRANSIENT)))
|
home.getState() != Node.TRANSIENT)))
|
||||||
child.setNode (crel.propName, home);
|
child.setNode (crel.propName, home);
|
||||||
} else {
|
} else if (crel.reftype == PRIMITIVE) {
|
||||||
|
child.setString (crel.propName, home.getID ());
|
||||||
|
}
|
||||||
|
} else if (crel.reftype == PRIMITIVE) {
|
||||||
String value = null;
|
String value = null;
|
||||||
if (ownType.isRelational ())
|
if (ownType.isRelational ())
|
||||||
value = home.getString (ownType.columnNameToProperty (localName), false);
|
value = home.getString (ownType.columnNameToProperty (localName), false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue