I used in Spring Data Neo4j 3.1.2 this query to create a person and get the id of it:
Create (n:Person {gender:'MALE',sic:'sic-123'}) return id(n)
with my Neo4JTemplate i execute this query with:
neo4JTemplate.query("Create (n:Person {gender:{gender},sic:{sic}}) "+
"return id(n)",ImmutableMap.of("gender","MALE","sic","sic-123");
Now i want to use Spring Data Neo4J 4.0.0.M1, because of it's server-support.
In SDN 4 queries can executed with the Neo4jTemplate by
void neo4jTemplate.execute(String jsonStatement)
//CREATE, MERGE or DELETE the node
or
<T> T queryForObject(Class<T> objectType, String cypher, Map<String,?> parameters)
//The RETURN of an Object possible but read only - mode (no creation)
<T> Iterable<T> queryForObjects(Class<T> objectType, String cypher,
Map<String,?> parameters)
//The RETURN of Objects possible but read only - mode (no creation)
Iterable<Map<String,Object>> query(String cypher,
Map<String,?> parameters)
//The RETURN of Objects possible but read only - mode (no creation)
My Question now is: how can i use the neo4jTemplate to use only ONE query that create my node and get me the id of it?
P.S.: The creation and return of the id works, but i want only one query to manage this problem.