0
votes

i did some experiments with neo4j 2.3 version and direct calls on transactional endpoint

http://localhost:7474/db/data/transaction/commit

and create the node with long attribute

curl -X POST -H "Content-Type: application/json" -d '{
"statements" : [ {
"statement" : "MERGE (c:`foo` {id:{_queryId}}) ON CREATE SET  c.`created`={created} RETURN c",
"parameters" : {
  "created" : 1111111111111111111
}}]
}'
"http://localhost:7474/db/data/transaction/commit"

While reading this data on client side (Java, Jersey , REST client) i receive the long or int depending the value It looks like neo4j is compacting the data while returning result I proof it with pure postman call - so this is clearly neo4j server side issue - as follows

{
 "statements" : [ {
 "statement" : "MATCH c RETURN TYPE(c.created)"
 } ]
}

And i got either

  "code": "Neo.DatabaseError.Statement.ExecutionFailure",
  "message": "java.lang.Long cannot be cast to org.neo4j.graphdb.Relationship",
  "stackTrace": "java.lang.ClassCastException: java.lang.Long cannot be cast to org.neo4j.graphdb.Relationship\

or

  "code": "Neo.DatabaseError.Statement.ExecutionFailure",
  "message": "java.lang.Integer cannot be cast to org.neo4j.graphdb.Relationship",
  "stackTrace": "java.lang.ClassCastException: java.lang.Integer cannot be cast to org.neo4j.graphdb.Relationship

Is there a way that as a consumer i could always get long ?

Regards

1

1 Answers

0
votes

That's actually due to the REST client. To be consistent, it's best to expect a java.lang.Number and then do a longValue() on it.

However, the exceptions you show in your post are because you're trying to use the TYPE function on a number. TYPE expects a relationship and it returns the relationship type.