- a Tag points to two generic objects. In this testcase source = AudioInstance and destination = ImageInstance.
- Tag.properties
- ----------------------------------
- src = object(HopObject)
- ....
- dst = object(HopObject)
- ...
- Image has a collection of tags sorted by tag_name with the accessname being the ID of the source-object. if i remove the accessname, my problems go away.
- Image.properties
- -----------------------------------
- tagsByName = collection(Tag)
- tagsByName.accessname = tag_f_source_id
- tagsByName.local.1 = $id
- tagsByName.foreign.1 = tag_f_target_id
- tagsByName.local.2 = $prototype
- tagsByName.foreign.2 = tag_f_target_prototype
- tagsByName.group = tag_name
- reproduce the problem:
- // get Image & Audio instances and attach them to Tag.
- // then add the Tag to the grouped collection of Image
- var img = Image.getById(1);
- var audio = Audio.getById(1);
- var tag = new Tag("viet");
- tag.src = img;
- tag.dst = audio;
- img.tagsByName.add(tag);
- // remove the tag = undo the above
- img.tagsByName.get(tag.title).removeChild(tag);
- img.tagsByName.removeChild(tag);
- tag.remove();
- // doing ONE of the following makes the last line of this action work
- // res.commit();
- // img.outboundRelations.get(rel.type).invalidate();
- var otherTag = new Tag("viet");
- otherTag.target = img;
- otherTag.src = audio;
- img.tagsByName.add(otherTag); // NPE error retrieving node exception
- ---------------
- gives me
- [2009/05/28 13:00:33] [ERROR] [dgr-1] Error retrieving Node "1" from HopObject#viet
- java.lang.NullPointerException
- at helma.objectmodel.db.Relation$Constraint.addToQuery(Relation.java:1414)
- at helma.objectmodel.db.Relation.renderConstraints(Relation.java:1042)
- at helma.objectmodel.db.Relation.buildQuery(Relation.java:906)
- at helma.objectmodel.db.NodeManager.getNodeByRelation(NodeManager.java:1625)
- at helma.objectmodel.db.NodeManager.getNode(NodeManager.java:278)
- at helma.objectmodel.db.WrappedNodeManager.getNode(WrappedNodeManager.java:87)
- at helma.objectmodel.db.Node.getChildElement(Node.java:1054)
- at helma.objectmodel.db.Node.addNode(Node.java:910)
- at helma.objectmodel.db.Node.addNode(Node.java:813)
- at helma.objectmodel.db.Node.addNode(Node.java:872)
- at helma.objectmodel.db.Node.addNode(Node.java:813)
- at helma.scripting.rhino.HopObject.jsFunction_add(HopObject.java:535)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:585)
- at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
- at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:476)
- at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
- at org.mozilla.javascript.gen.c258._c2(/home/oberhams/experiments/demo-generic-reference/Root/actions.js:27)