Santosh Joshi
Santosh Joshi

Reputation: 3320

Spring Data Neo4j anotated query not returning desired results

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.

Upvotes: 0

Views: 121

Answers (2)

Michael Hunger
Michael Hunger

Reputation: 41676

Don't quote parameters:

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

Upvotes: 2

gmjordan
gmjordan

Reputation: 314

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);

Upvotes: 0

Related Questions