* Parse additional join conditions for child collections as defined in

http://helma.org/stories/47853/
* When enforcing constraints try to preserve the type of the original
  property using the new Node.set() method.
This commit is contained in:
hns 2003-04-23 12:38:30 +00:00
parent 4501c5cf50
commit ec55ce1042

View file

@ -251,6 +251,19 @@ public final class Relation {
cnst.addElement(new Constraint(local, otherType.getTableName(), foreign, false)); cnst.addElement(new Constraint(local, otherType.getTableName(), foreign, false));
columnName = local; columnName = local;
} }
// parse additional contstraints
for (int i=1; i<10; i++) {
local = props.getProperty(propName + ".local."+i);
foreign = props.getProperty(propName + ".foreign."+i);
if ((local != null) && (foreign != null)) {
cnst.addElement(new Constraint(local, otherType.getTableName(), foreign, false));
} else {
break;
}
}
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -682,7 +695,7 @@ public final class Relation {
* appropriate properties * appropriate properties
*/ */
public void setConstraints(Node parent, Node child) { public void setConstraints(Node parent, Node child) {
INode home = parent.getNonVirtualParent(); Node home = parent.getNonVirtualParent();
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
@ -717,16 +730,17 @@ public final class Relation {
child.setString(crel.propName, home.getID()); child.setString(crel.propName, home.getID());
} }
} else if (crel.reftype == PRIMITIVE) { } else if (crel.reftype == PRIMITIVE) {
String value = null; Property prop = null;
if (ownType.isRelational()) { if (ownType.isRelational()) {
value = home.getString(ownType.columnNameToProperty(localName)); prop = home.getProperty(ownType.columnNameToProperty(localName));
// value = home.getString(ownType.columnNameToProperty(localName));
} else { } else {
value = home.getString(localName); prop = home.getProperty(localName);
} }
if (value != null) { if (prop != null) {
child.setString(crel.propName, value); child.set(crel.propName, prop.getValue(), prop.getType());
} }
} }
} }