This short blog post explains how to use Cypher Querydsl with eXtended Objects and Neo4j Datastore. Read the “Getting started with Composite Data Objects and Neo4j” if you are not familiar with the eXtended Objects Framework. The project has been renamed to “eXtended Objects” since this “Getting Started” blog post has been published – just in case you wonder about the different name.

Simple Example

A simple example might be an entity Person that looks as follows:

public interface Person {
    String getName();
    void setName(String name);

Adding the required dependencies

Add the following dependencies to the dependencies section of your Maven project:



Configuring the APT Maven Plugin

We now have to configure the APT Maven Plugin which looks as follows:

                <!-- the directory in which the query types get generated -->
                <!-- the annotation processor to be used -->

Now start the source generation by running

mvn generate-sources

After the generate-sources goal ran successfully you can find the newly created query types in the configured outputDirectory. In our example is generated which can be used by our sample application as follows:

// initialize XOManager object
final XOManager xoManager = getXoManager();

// create a Person object with name "Morpheus"
Person person = xoManager.create(Person.class);

// create a query object by using the fluent Cypher DSL
QPerson p = QPerson.person;
Execute execute = start(allNodes(identifier(p)))

// execute the built Cypher query by using XO API
Person result = xoManager.createQuery(execute.toString(), Person.class)

// validate the result
assertThat(person, equalTo(result));


The XO Annotation Processor lets you generate Querydsl query types which can easily be used to build Cypher queries by using the Cypher-DSL developed by the Neo4j team.