On Wed, Jul 2, 2008 at 4:48 PM, Peter Haensgen <[EMAIL PROTECTED]> wrote: > Hi, > >> > Are there any reasons for comparing nodes by their id and not use >> equals()? > > a node can be identified by its id. So you can compare two nodes like: > > if (aNode.getId() == bNode.getId()) ... > > Node is only an interface. The actual instance that you get has a > different class (some proxy). From my observations it is not guaranteed > that you always get the same node proxy object when you access the same > node, e.g. if aNode and bNode represent the same node in the database, > then > > aNode.getId() == bNode.getId() --> true, but > aNode == bNode --> very likely false > > The proxy class that implements the Node interface therefore should > override the equals() method and compare the ids instead. I don't know > if that has been done, but I would think so. >
Yes. All implementations of Node or Relationship interfaces have equals overridden. So always compare using id or equals method. Never use object reference compare since they may be different (this is true for relationship types too). -- Johan _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user