[Neo] relationship.getOtherNode(localnode) returning null?

Johan Svensson johan at neopersistence.com
Thu Jun 21 12:23:36 CEST 2007

On 6/21/07, Emil Eifrem <emil at neopersistence.com> wrote:
> On 6/20/07, Peter Neubauer <peter.neubauer at jayway.se> wrote:
> > Hi there,
> > not sure this is trivial but relationship.getOtherNode(localnode) is
> > giving me null in some cases. Can this occur and what is the reason
> > for it?
> This should not happen. The API specs at
> http://api.neo4j.org/1.0-b5/org/neo4j/api/core/Relationship.html#getOtherNode(org.neo4j.api.core.Node)
> is very clear that the only thing that can be returned is the start or
> end node of the relationship, or a runtime exception if the client
> passes in a node that's not connected to either end of the
> relationship. It should never return null.
> So it's a bug. Not sure when the current implementation can
> (erroneously) return null. Johan may be able to shed some light on
> that?

The current implementation will return null if node passed in isn't
connected to the relationship, so if node N1 and node N2 are connected via
relationship R. R.getOtherNode( Nx ) will return null for all Nx except N1
and N2. This will be changed to throw runtime exception instead.


More information about the User mailing list