I have already posted this on StackOverflow, but haven't gotten any 
answers. I suspect there may be a bug involved, or it's just a gotcha that 
I must have missed somewhere. I have tried everything I could think of, and 
checked the documentation but still can't find the reason why my nodes 
can't be mapped even after adding the correct primary SDN label.

I'm running SDN 3.0.2.RELEASE and neo4j 2.0.3 on arch linux x64 with Oracle 
Java 1.8.0_05

Trying to retrieve nodes in SDN, imported using the Neo4j CSV Batch 
Importer<https://github.com/jexp/batch-import>, 
gives the java.lang.IllegalStateException:

java.lang.IllegalStateException: No primary SDN label exists .. (i.e one with 
starting  with _)

This is after having added a new label through a cypher query:

match (n:Movie) set n:_Movie;

Inspecting nodes created through SDN shows they have the same labels. The 
result when running

match (n) where id(n)={nodeId} return labels(n) as labels;

as found in 
LabelBasedStrategyCypher.java<https://github.com/spring-projects/spring-data-neo4j/blob/1bd9c20787c2589b84cc1f3498675ea34d5c13e3/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/typerepresentation/LabelBasedStrategyCypherHelper.java>
 is 
the same for both:

["Movie","_Movie"]

Saving and retrieving nodes thorugh SDN works without any issues. I must be 
missing something as I got the impression that setting the appropiate 
labels<http://neo4j.com/blog/spring-data-neo4j-progress-update-sdn-3-neo4j-2> 
should 
be enough.

My CSV file looks like this. The appId is only used to assure the node is 
the same that we have stored earlier, as the internal nodeId is Garbage 
collected <http://api.neo4j.org/2.0.3/org/neo4j/graphdb/Node.html> and new 
nodes could get old nodeIds after the old ones are deleted. The nodeId is 
used for actual lookups and for connecting relationships and so on.

appId:int   l:label title:string:movies year:int1   Movie   Dinosaur Planet 
20032   Movie   Isle of Man TT 2004 Review  2004

I have made more tests, checking the source of 
LabelBasedNodeTypeRepresentationStrategy to see what is going wrong. 
Running the readAliasFrom() method that the Exception is thrown from does 
not return any errors:

String query = "start n=node({id}) return n";Node node = null;for(Node n : 
neo4jTemplate.query(query,params).to(Node.class)){
    node = n;}
// when running the readAliasFrom method manually the label is returned 
correctlyLabelBasedNodeTypeRepresentationStrategy strategy = new 
        
LabelBasedNodeTypeRepresentationStrategy(neo4jTemplate.getGraphDatabase());System.out.println("strategy
 returns:  " +(String)strategy.readAliasFrom(node));
// trying to convert the node to a movie object, however throws the Illegal 
State ExceptionMovie movie = null;
movie = neo4jTemplate.convert(node,Movie.class);

So, the _Movie label exists, running the readAliasFrom() method manually 
doesn't throw Exceptions but trying to convert the node into a Movie does. 
Nodes created from SDN do not have these issues, even if they look 
identical to me.

/Manuel

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to