diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/CypherDslRepositoryTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/CypherDslRepositoryTest.java index 173290112..117ec59c4 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/CypherDslRepositoryTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/CypherDslRepositoryTest.java @@ -15,21 +15,14 @@ */ package org.springframework.data.neo4j.repository; -import com.mysema.query.types.expr.Param; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.neo4j.cypherdsl.CypherQuery; + +import static org.neo4j.cypherdsl.CypherQuery.*; +import static org.neo4j.cypherdsl.querydsl.CypherQueryDSL.*; import org.neo4j.cypherdsl.Execute; -import org.neo4j.cypherdsl.OrderBy; -import org.neo4j.cypherdsl.query.Expression; -import org.neo4j.cypherdsl.query.ReturnExpression; -import org.neo4j.cypherdsl.query.StartExpression; -import org.neo4j.cypherdsl.query.WhereExpression; import org.neo4j.cypherdsl.querydsl.CypherQueryDSL; -import org.neo4j.cypherdsl.querydsl.QueryDSLReturnExpression; -import org.neo4j.cypherdsl.querydsl.QueryDSLStartExpression; -import org.neo4j.cypherdsl.querydsl.QueryDSLWhere; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -66,10 +59,10 @@ public class CypherDslRepositoryTest { @Autowired Neo4jOperations template; private TestTeam team; private Map peopleParams; - private Execute query = CypherQuery.start(StartExpression.node("n", "people")).returns(ReturnExpression.nodes("n")); - private Execute query2 = CypherQueryDSL.start(QueryDSLStartExpression.node(QPerson.person, "people")). + private Execute query = start(node("n", "people")).returns(identifier("n")); + private Execute query2 = CypherQueryDSL.start(CypherQueryDSL.node(QPerson.person, "people")). where(QPerson.person.name.eq("Michael")). - returns(QueryDSLReturnExpression.nodes(QPerson.person)); + returns(identifier(QPerson.person)); @Before public void setUp() throws Exception { diff --git a/src/docbkx/reference/programming-model/repositories.xml b/src/docbkx/reference/programming-model/repositories.xml index 923a53fb6..b99ea0202 100644 --- a/src/docbkx/reference/programming-model/repositories.xml +++ b/src/docbkx/reference/programming-model/repositories.xml @@ -272,8 +272,10 @@ Iterable findByParentAgeAndMarried(int age, boolean married) Examples for Cypher-DSL repository - , CypherDslRepository {} @@ -282,7 +284,7 @@ Iterable findByParentAgeAndMarried(int age, boolean married) Execute query = start( lookup( "company", "Company", "name", param("name") ) ). match( path().from( "company" ).in( "WORKS_AT" ).to( "person" )). - returns( nodes( "person" )) + returns( identifier( "person" )) Page people = repo.query(query , map("name","Neo4j"), new PageRequest(1,10)); QPerson person = QPerson.person; @@ -290,7 +292,7 @@ Iterable findByParentAgeAndMarried(int age, boolean married) Execute query = start( lookup( company, "Company", company.name, param("name") ) ). match( path().from( company ).in( "WORKS_AT" ).to( person ). .where(person.firstName.like("P*").and(person.age.gt(25))). - returns( nodes( person )) + returns( identifier(person) ) EndResult people = repo.query(query , map("name","Neo4j")); ]]> @@ -299,6 +301,36 @@ Iterable findByParentAgeAndMarried(int age, boolean married)
CypherDSL and QueryDSL + + To use Cypher-DSL with QueryDSL the Mysema dependencies have to be declared explicitly as they are + optional in the CypherDSL project. + + + com.mysema.querydsl + querydsl-core + 2.2.3 + true + + + com.mysema.querydsl + querydsl-lucene + 2.2.3 + true + + + org.apache.lucene + lucene-core + + + + + com.mysema.querydsl + querydsl-apt + 2.2.3 + provided + +]]> + It is possible to use the Cypher DSL along with the predicates and code generation features of the QueryDSL project. This will allow you to use Java objects as part of the query, rather than strings, for the names of properties and such. In order to get this to work you first have