Merge branch 'gremlin'

This commit is contained in:
Michael Hunger
2011-07-25 16:52:21 +02:00
40 changed files with 487 additions and 579 deletions

View File

@@ -48,6 +48,15 @@
The current version that does not show incorrect errors is AspectJ 1.6.12.M1 (included in STS 2.7.0.M2), previous versions are reported
to mislead the user.
</para>
<note>
<para>
There might be some issues with the eclipse maven plugin not adding AspectJ files correctly to the build path. If you encounter issues, please try the following:
Try editing the build path to <code>include **/*.aj</code> for the spring-data-neo4j project.
You can do this by selecting "Build Path -> Configure Build Path ..." from the Package Explorer.
Then for the <code>spring-data-neo4j/src/main/java</code> add <code>**/*.aj</code> to the Included path.
</para>
</note>
<para>
The AspectJ support in IntelliJ IDEA lacks some of the features. JetBrains is working on improving
the situation in their upcoming 10.5 release of their popular IDE. Their latest work is available

View File

@@ -114,19 +114,19 @@
</listitem>
</varlistentry>
<varlistentry>
<term>Executes the given query, replacing the first %d with the node-id and returning the results converted to the target type.</term>
<term>Executes the given query, replacing <code>%start</code> with the node-id and returning the results converted to the target type.</term>
<listitem>
<para><code>&lt;T&gt; Iterable&lt;T&gt; NodeBacked.findAllByQuery(final String query, final Class&lt;T&gt; targetType)</code></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Executes the given query, replacing the first %d with the node-id and returning the original result, but with nodes and relationships replaced by their appropriate entities.</term>
<term>Executes the given query, replacing <code>%start</code> with the node-id and returning the original result, but with nodes and relationships replaced by their appropriate entities.</term>
<listitem>
<para><code>Iterable&lt;Map&lt;String,Object&gt;&gt; NodeBacked.findAllByQuery(final String query)</code></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Executes the given query, replacing the first %d with the node-id and returns a single result converted to the target type.</term>
<term>Executes the given query, replacing <code>%start</code> with the node-id and returns a single result converted to the target type.</term>
<listitem>
<para><code>&lt;T&gt; T NodeBacked.findByQuery(final String query, final Class&lt;T&gt; targetType)</code></para>
</listitem>

View File

@@ -72,28 +72,33 @@ public class Movie {
</section>
<section>
<title>@GraphQuery: fields as query result views</title>
<title>@Query: fields as query result views</title>
<para>
The <code>@GraphQuery</code> annotation leverages the delegation infrastructure used by the
The <code>@Query</code> annotation leverages the delegation infrastructure used by the
Spring Data Graph aspects. It provides dynamic fields which, when accessed, return the values
selected by the provided query language expression. The provided query must contain a placeholder
for the id of the current entity <code>start n=(%d) match n-[:FRIEND]->friend return friend</code>
As graph queries can return variable number of entities the annotation can be put onto fields
with a single value, an Iterable of a type or an Iterable of <code>Map&lt;String,Object&gt;</code>.
The class of the resulting node entities must right now provided with the <code>elementClass</code> attribute.
Additional parameters are added to the query with Java's String.format substitution.
selected by the provided query language expression. The provided query must contain a placeholder named <code>%start</code>
for the id of the current entity. For instance <code>start n=(%start) match n-[:FRIEND]->friend return friend</code>.
Graph queries can return variable number of entities. That's why annotation can be put onto fields
with a single value, an Iterable of a concrete type or an Iterable of <code>Map&lt;String,Object&gt;</code>.
Additional parameters are taken from the params attribute of the <code>@Query</code> annotation.
The tuples form key-value pairs that are provided to the query at execution time.
</para>
<example>
<title>@GraphQuery from a node entity</title>
<title>@Graph on a node entity field</title>
<programlisting language="java"><![CDATA[@NodeEntity
public class Group {
@GraphQuery(value = "start n=(%d) match (n)-[:%s]->(friend) return friend",
elementClass = Person.class, params = "FRIEND")
@Query(value = "start n=(%start) match (n)-[:%relType]->(friend) return friend",
params = {"relType", "FRIEND"})
private Iterable<Person> friends;
}
]]></programlisting>
</example>
<para>
<note>
Please note that this annotation can also be used on repository methods.
</note>
</para>
</section>
<section>
<title>@GraphTraversal: fields as traversal result views</title>

View File

@@ -132,13 +132,16 @@
<section>
<title>Annotated Queries</title>
<para>
Queries for the graph-query language cypher can be supplied with the <code>@GraphQuery</code> annotation.
That means every method annotated with <code>@GraphQuery("start n=(%d) match (n)-->(m) return m")</code>
will use the query string. The String-format parameters are replaced by the actual method parameters in order,
whereby Node and Relationship-Entities are resolved to their respective id's and all other parameters are
Queries for the cypher graph-query language can be supplied with the <code>@Query</code> annotation.
That means every method annotated with <code>@Query("start n=(%node) match (n)-->(m) return m")</code>
will use the query string. The named parameter <code>%node</code> will be replaced by the actual method parameters.
Node and Relationship-Entities are resolved to their respective id's and all other parameters are
replaced directly (i.e. Strings, Longs, etc). There is special support for the <code>Sort</code> and <code>Pageable</code>
parameters from Spring Data Commons, which are supported to add programmatic paging and sorting (alternatively
static paging and sorting can be supplied in the query string itself).
For using the named parameters you have to either annotate the parameters of the method with the
<code>@Param("node")</code> annotation or enable debug symbols.
</para>
</section>
@@ -146,8 +149,9 @@
<title>Named Queries</title>
<para>Spring Data Graph also supports the notion of named queries which are externalized in property-config-files
(<code>META-INF/graph-named-queries.properties</code>). Those files have the format:
<code>Entity.finderName=query</code> (e.g. <code>Person.findBoss=start p=(%d) match (p)&lt;-[:BOSS]-(boss) return boss</code>).
Otherwise named queries support the same parameters as annotated queries.
<code>Entity.finderName=query</code> (e.g. <code>Person.findBoss=start p=(%person) match (p)&lt;-[:BOSS]-(boss) return boss</code>).
Otherwise named queries support the same parameters as annotated queries. For using the named parameters you have to either
annotate the parameters of the method with the <code>@Param("person")</code> annotation or enable debug symbols.
</para>
</section>
<section>