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. > Why is equals() not part of the Node/Relationship API -- but still used > in example code in the Relationship apidocs ? equals() is defined in java.lang.Object. Since every class in Java automatically inherits from java.lang.Object (directly or indirectly), every object has an equals method (which by default checks for object identity, e.g. a == b). You don't have to declare it in an interface (though you can). It would make no difference. > What if an implementation of Node/Relationship doesn't override equals() ? Then the default behavior that is implemented in java.lang.Object applies, e.g. a == b. Ciao, Peter _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user