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

Johan Svensson johan at neopersistence.com
Wed Jun 27 14:05:45 CEST 2007


Wasn't really able to parse the code but a quick glance and my
instinct says that you should have Direction.INCOMING instead of
Direction.OUTGOING for second iteration. Am I right?

If I am wrong please explain what it is you're trying to do and I'll
help you accomplish it.

-Johan

On 6/27/07, Peter Neubauer <peter.neubauer at jayway.se> wrote:
> Well,
> two problems here. First the code givign me null is this:
> public int cmdLs(Dictionary opts, Reader in, PrintWriter out,
>             Session session) {
>         TransactionUtil.beginTx();
>         Node localnode = currentNode;
>         String[] ids = (String[]) opts.get("id");
>         if(ids.length == 1)
>         {
>                 localnode = neo.getNodeById(Long.parseLong(ids[0]));
>         }
>         Iterable<Relationship> relationships =
> localnode.getRelationships(Direction.OUTGOING);
>         for (Relationship relationship : relationships) {
>                         out.println(localnode.getId() + "--->" +
> nodeToString(relationship.getOtherNode(localnode)));
>                 }
>         Iterable<Relationship> incomingRelationships =
> currentNode.getRelationships(Direction.OUTGOING);
>         for (Relationship relationship : incomingRelationships) {
>                         out.println(localnode.getId() + "<---" +
> nodeToString(relationship.getOtherNode(localnode)));
>                 }
>         TransactionUtil.finishTx(true, true);
>         return 0;
>     }
>
> Throwing a null into nodeToString(Node).
>
> Secondly, Direction.OUTGOING gives med the same nodes as
> Direction.INCOMING. Is that intended and is it relevant at all, in
> that case, should it be removed?
>
> /peter
>
>


More information about the User mailing list