Make getChildElement smart enough to actually look at the DbMapping of the

Node when trying to fetch a child element. As a side effect, retrieving a child
object by ID when an accessname is defined for the child collection and no
object was found using the accessname column does not work anymore.
This commit is contained in:
hns 2002-09-17 17:02:17 +00:00
parent 9abb4cc1e4
commit 0c4ae4da46

View file

@ -902,11 +902,24 @@ public final class Node implements INode, Serializable {
* This implements the getChild() method of the IPathElement interface * This implements the getChild() method of the IPathElement interface
*/ */
public IPathElement getChildElement (String name) { public IPathElement getChildElement (String name) {
if (dbmap != null) {
// if a dbmapping is provided, check what it tells us about
// getting this specific child element
Relation rel = dbmap.getExactPropertyRelation (name);
if (rel != null)
return (IPathElement) getNode (name, false);
rel = dbmap.getSubnodeRelation ();
if (rel != null && rel.groupby == null && rel.accessor != null)
return (IPathElement) nmgr.getNode (this, name, rel);
return (IPathElement) getSubnode (name);
} else {
// no dbmapping - just try child collection first, then named property.
IPathElement child = (IPathElement) getSubnode (name); IPathElement child = (IPathElement) getSubnode (name);
if (child == null) if (child == null)
child = (IPathElement) getNode (name, false); child = (IPathElement) getNode (name, false);
return child; return child;
} }
}
/** /**
* This implements the getParentElement() method of the IPathElement interface * This implements the getParentElement() method of the IPathElement interface