[Neo4j] getProperty returning wrong value

Mattias Persson mattias at neotechnology.com
Tue Jul 13 15:57:33 CEST 2010


2010/7/13, Tim Jones <bogologo at ymail.com>:
> Hi,
>
> I'm traversing a Node set, calling getProperty on each node. However, the
> value
> returned is always '1', even if this isn't the value of the property. I've
> confirmed in neoclipse that one specific node has a 'count' property of 2,
> but
> when I debug my code, the value '1' is returned for that node.
>
> Below is my code. Am I using transactions correctly, or do I need to start a
> new
> Transaction for each read operation (i.e. inside the 'for' loop)?

No, how ever you group your read operations it returns correct values,
so it feels quite odd that wrong values are returned... I think you
need to verify this a bit more. Maybe look up a node with count=2 in
neoclipse and then see if that node gets returned by your query and
really returns count=1.

>
> Thanks,
> Tim
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
>
> try
>         {
>             userPathService.beginTransaction();
>
>             Page startPage = lookupSearchService.searchPage(url);
>
>             Node startNode = startPage.getUnderlyingNode();
>
>             // traverse over all Route nodes related to the start node
>             Traverser traverser = startNode.traverse(
>                     Order.BREADTH_FIRST,
>                     StopEvaluator.DEPTH_ONE,
>                     ReturnableEvaluator.ALL_BUT_START_NODE,
>                     Relationships.ROUTE, Direction.INCOMING);
>
>             // add all the nodes to an array
>             Map<Integer, List<String>> routes = new HashMap<Integer,
> List<String>>();
>             List<String> pathList;
>             Route route;
> // debug variables
> Integer count;
> String myPath;
>             for (Node routeNode : traverser)
>             {
>                 route = new Route(routeNode);
>
>                 if (!routes.containsKey(route.getCount()))
>                 {
>                     routes.put(route.getCount(), new ArrayList<String>());
>                 }
> // the following is always set to '1'
> count = route.getCount();
> // the correct path is always returned
> myPath = route.getPath();
>                 pathList = routes.get(route.getCount());
>                 pathList.add(route.getPath());
>             }
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> // the Route class:
> public static final String COUNT = "count";
> public Integer getCount()
>     {
>         return (Integer)node.getProperty(COUNT);
>     }
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
>
>
>
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>


-- 
Mattias Persson, [mattias at neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com


More information about the User mailing list