From 0c4ae4da469cda8149705d88a8a40dcc93a4a58b Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 17 Sep 2002 17:02:17 +0000 Subject: [PATCH] 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. --- src/helma/objectmodel/db/Node.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 0eeb444b..4c1167d8 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -902,10 +902,23 @@ public final class Node implements INode, Serializable { * This implements the getChild() method of the IPathElement interface */ public IPathElement getChildElement (String name) { - IPathElement child = (IPathElement) getSubnode (name); - if (child == null) - child = (IPathElement) getNode (name, false); - return child; + 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); + if (child == null) + child = (IPathElement) getNode (name, false); + return child; + } } /**