Question

I am not able to get data from neo4j server using the spring data annotated query, though data exists in the server, also if i use the same query and paste it in neo4j console it works well and returns me the below data:

----------------------------------------------------------------------------+
| n                                                                         |
+---------------------------------------------------------------------------+
| Node[25503]{id:1388107845,name:"Cricket",__type__:"com.domain.Sport"}     |
+---------------------------------------------------------------------------+

The anotated spring data query is

@Query("match n where n.__type__='com.domain.Sport' and n.name='{0}' return n;")
public Sport getSportWithName(String sportName);

Any insights on what is wrong with this query.

Was it helpful?

Solution

Don't quote parameters:

@Query("match n where n.__type__='com.domain.Sport' and n.name={0} return n")
public Sport getSportWithName(String sportName);

OTHER TIPS

Are you using @TypeAlias on com.domain.Sport?

If so, try using the alias value in the query:

@Query("match n where n.__type__='Sport' and n.name='{0}' return n;")
public Sport getSportWithName(String sportName);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top