renaming spring data graph to spring data neo4j
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<project name="spring-data-graph-example" default="test" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
|
<project name="spring-data-neo4j-example" default="test" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
|
||||||
<property name="settings.dir" location="settings" />
|
<property name="settings.dir" location="settings" />
|
||||||
<property name="lib.dir" location="lib" />
|
<property name="lib.dir" location="lib" />
|
||||||
|
|
||||||
|
|||||||
32
pom.xml
32
pom.xml
@@ -3,14 +3,14 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-graph-dist</artifactId>
|
<artifactId>spring-data-neo4j-dist</artifactId>
|
||||||
<name>Spring Data Graph Distribution</name>
|
<name>Spring Data Neo4j Distribution</name>
|
||||||
<description><![CDATA[Within the Spring Data project the Spring Data Graph library provides integration with the Neo4j graph database, offering object graph mapping, a Neo4jTemplate and Spring-Data-Commons Repository implementations.
|
<description><![CDATA[Within the Spring Data project the Spring Data Neo4j library provides integration with the Neo4j graph database, offering object graph mapping, a Neo4jTemplate and Spring-Data-Commons Repository implementations.
|
||||||
]]></description>
|
]]></description>
|
||||||
<version>1.2.0.BUILD-SNAPSHOT</version>
|
<version>1.2.0.BUILD-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>spring-data-graph-parent</module>
|
<module>spring-data-neo4j-parent</module>
|
||||||
<module>spring-data-neo4j</module>
|
<module>spring-data-neo4j</module>
|
||||||
<module>spring-data-neo4j-rest</module>
|
<module>spring-data-neo4j-rest</module>
|
||||||
</modules>
|
</modules>
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
<url>http://www.springsource.com</url>
|
<url>http://www.springsource.com</url>
|
||||||
</organization>
|
</organization>
|
||||||
<scm>
|
<scm>
|
||||||
<url>http://github.com/SpringSource/spring-data-graph</url>
|
<url>http://github.com/SpringSource/spring-data-neo4j</url>
|
||||||
<connection>scm:git:git://github.com/SpringSource/spring-data-graph.git</connection>
|
<connection>scm:git:git://github.com/SpringSource/spring-data-neo4j.git</connection>
|
||||||
<developerConnection>scm:git:git://github.com/SpringSource/spring-data-graph.git</developerConnection>
|
<developerConnection>scm:git:git://github.com/SpringSource/spring-data-neo4j.git</developerConnection>
|
||||||
</scm>
|
</scm>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>JIRA</system>
|
<system>JIRA</system>
|
||||||
@@ -151,15 +151,15 @@
|
|||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<site>
|
<site>
|
||||||
<id>spring-site-staging</id>
|
<id>spring-site-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/docs/${project.version}</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/docs/${project.version}</url>
|
||||||
</site>
|
</site>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-milestone-staging</id>
|
<id>spring-milestone-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/milestone</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/milestone</url>
|
||||||
</repository>
|
</repository>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>spring-snapshot-staging</id>
|
<id>spring-snapshot-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/snapshot</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/snapshot</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
</profile>
|
</profile>
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
<downloadUrl>http://www.springsource.com/spring-data</downloadUrl>
|
<downloadUrl>http://www.springsource.com/spring-data</downloadUrl>
|
||||||
<site>
|
<site>
|
||||||
<id>static.springframework.org</id>
|
<id>static.springframework.org</id>
|
||||||
<url>scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-data/data-graph/snapshot-site/</url>
|
<url>scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-data/data-neo4j/snapshot-site/</url>
|
||||||
</site>
|
</site>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-release</id>
|
<id>spring-release</id>
|
||||||
@@ -291,7 +291,7 @@
|
|||||||
<highlightDefaultLanguage></highlightDefaultLanguage-->
|
<highlightDefaultLanguage></highlightDefaultLanguage-->
|
||||||
<postProcess>
|
<postProcess>
|
||||||
<copy file="${basedir}/target/docbkx/rtf/index.rtf"
|
<copy file="${basedir}/target/docbkx/rtf/index.rtf"
|
||||||
tofile="${basedir}/target/site/reference/rtf/spring-data-graph-reference.rtf"
|
tofile="${basedir}/target/site/reference/rtf/spring-data-neo4j-reference.rtf"
|
||||||
failonerror="false"/>
|
failonerror="false"/>
|
||||||
</postProcess>
|
</postProcess>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -311,7 +311,7 @@
|
|||||||
<highlightDefaultLanguage></highlightDefaultLanguage>
|
<highlightDefaultLanguage></highlightDefaultLanguage>
|
||||||
<postProcess>
|
<postProcess>
|
||||||
<copy file="${basedir}/target/docbkx/pdf/index.pdf"
|
<copy file="${basedir}/target/docbkx/pdf/index.pdf"
|
||||||
tofile="${basedir}/target/site/reference/pdf/spring-data-graph-reference.pdf"
|
tofile="${basedir}/target/site/reference/pdf/spring-data-neo4j-reference.pdf"
|
||||||
failonerror="false"/>
|
failonerror="false"/>
|
||||||
</postProcess>
|
</postProcess>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -392,7 +392,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<javadoc:aggregate>true</javadoc:aggregate>
|
<javadoc:aggregate>true</javadoc:aggregate>
|
||||||
<breakiterator>true</breakiterator>
|
<breakiterator>true</breakiterator>
|
||||||
<header>Spring Data Graph</header>
|
<header>Spring Data Neo4j</header>
|
||||||
<source>1.6</source>
|
<source>1.6</source>
|
||||||
<quiet>true</quiet>
|
<quiet>true</quiet>
|
||||||
<javadocDirectory>${project.basedir}/src/main/javadoc</javadocDirectory>
|
<javadocDirectory>${project.basedir}/src/main/javadoc</javadocDirectory>
|
||||||
@@ -471,8 +471,8 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<!-- the name of this project is 'spring-data-graph-dist';
|
<!-- the name of this project is 'spring-data-neo4j-dist';
|
||||||
make sure the zip file is just 'spring-data-graph'. -->
|
make sure the zip file is just 'spring-data-neo4j'. -->
|
||||||
<finalName>${dist.finalName}</finalName>
|
<finalName>${dist.finalName}</finalName>
|
||||||
</build>
|
</build>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-graph-parent</artifactId>
|
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||||
<name>Spring Data Graph Parent</name>
|
<name>Spring Data Neo4j Parent</name>
|
||||||
<version>1.2.0.BUILD-SNAPSHOT</version>
|
<version>1.2.0.BUILD-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<description><![CDATA[Spring Data Graph parent project. Defines dependencies and common configuration for the build process.
|
<description><![CDATA[Spring Data Neo4j parent project. Defines dependencies and common configuration for the build process.
|
||||||
]]></description>
|
]]></description>
|
||||||
<url>http://www.springsource.org/spring-data/neo4j</url>
|
<url>http://www.springsource.org/spring-data/neo4j</url>
|
||||||
<organization>
|
<organization>
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
<url>http://www.springsource.com</url>
|
<url>http://www.springsource.com</url>
|
||||||
</organization>
|
</organization>
|
||||||
<scm>
|
<scm>
|
||||||
<url>http://github.com/SpringSource/spring-data-graph</url>
|
<url>http://github.com/SpringSource/spring-data-neo4j</url>
|
||||||
<connection>scm:git:git://github.com/SpringSource/spring-data-graph.git</connection>
|
<connection>scm:git:git://github.com/SpringSource/spring-data-neo4j.git</connection>
|
||||||
<developerConnection>scm:git:git://github.com/SpringSource/spring-data-graph.git</developerConnection>
|
<developerConnection>scm:git:git://github.com/SpringSource/spring-data-neo4j.git</developerConnection>
|
||||||
</scm>
|
</scm>
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>JIRA</system>
|
<system>JIRA</system>
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
<org.mockito.version>1.8.4</org.mockito.version>
|
<org.mockito.version>1.8.4</org.mockito.version>
|
||||||
<org.slf4j.version>1.6.1</org.slf4j.version>
|
<org.slf4j.version>1.6.1</org.slf4j.version>
|
||||||
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
|
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
|
||||||
<data.commons.version>1.1.0.RELEASE</data.commons.version>
|
<data.commons.version>1.2.0.BUILD-SNAPSHOT</data.commons.version>
|
||||||
<neo4j.version>1.4.1</neo4j.version>
|
<neo4j.version>1.4.1</neo4j.version>
|
||||||
<aspectj.version>1.6.12.M1</aspectj.version>
|
<aspectj.version>1.6.12.M1</aspectj.version>
|
||||||
<blueprints.version>0.8</blueprints.version>
|
<blueprints.version>0.8</blueprints.version>
|
||||||
@@ -142,15 +142,15 @@
|
|||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<site>
|
<site>
|
||||||
<id>spring-site-staging</id>
|
<id>spring-site-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/docs/${project.version}</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/docs/${project.version}</url>
|
||||||
</site>
|
</site>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-milestone-staging</id>
|
<id>spring-milestone-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/milestone</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/milestone</url>
|
||||||
</repository>
|
</repository>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>spring-snapshot-staging</id>
|
<id>spring-snapshot-staging</id>
|
||||||
<url>file:///${java.io.tmpdir}/spring-data/data-graph/snapshot</url>
|
<url>file:///${java.io.tmpdir}/spring-data/data-neo4j/snapshot</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
</profile>
|
</profile>
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
<site>
|
<site>
|
||||||
<id>static.springframework.org</id>
|
<id>static.springframework.org</id>
|
||||||
<url>
|
<url>
|
||||||
scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-data/data-graph/docs/${project.version}
|
scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-data/data-neo4j/docs/${project.version}
|
||||||
</url>
|
</url>
|
||||||
</site>
|
</site>
|
||||||
<repository>
|
<repository>
|
||||||
@@ -571,7 +571,7 @@
|
|||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<strictCheck>true</strictCheck>
|
<strictCheck>true</strictCheck>
|
||||||
<header>${basedir}/../spring-data-graph-parent/license-header.txt</header>
|
<header>${basedir}/../spring-data-neo4j-parent/license-header.txt</header>
|
||||||
<includes>
|
<includes>
|
||||||
<include>src/**/*.java</include>
|
<include>src/**/*.java</include>
|
||||||
<include>src/**/*.js</include>
|
<include>src/**/*.js</include>
|
||||||
@@ -3,14 +3,14 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-graph-parent</artifactId>
|
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||||
<version>1.2.0.BUILD-SNAPSHOT</version>
|
<version>1.2.0.BUILD-SNAPSHOT</version>
|
||||||
<relativePath>../spring-data-graph-parent/pom.xml</relativePath>
|
<relativePath>../spring-data-neo4j-parent/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-data-neo4j-rest</artifactId>
|
<artifactId>spring-data-neo4j-rest</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Spring Data Graph REST Wrapper</name>
|
<name>Spring Data Neo4j REST Wrapper</name>
|
||||||
<description><![CDATA[Spring Data Graph Wrapper for the Neo4j REST API, provides a Graph Database proxy for the remote invocation.
|
<description><![CDATA[Spring Data Neo4j Wrapper for the Neo4j REST API, provides a Graph Database proxy for the remote invocation.
|
||||||
]]></description>
|
]]></description>
|
||||||
<url>http://www.springsource.org/spring-data/neo4j</url>
|
<url>http://www.springsource.org/spring-data/neo4j</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-graph-parent</artifactId>
|
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||||
<version>1.2.0.BUILD-SNAPSHOT</version>
|
<version>1.2.0.BUILD-SNAPSHOT</version>
|
||||||
<relativePath>../spring-data-graph-parent/pom.xml</relativePath>
|
<relativePath>../spring-data-neo4j-parent/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-data-neo4j</artifactId>
|
<artifactId>spring-data-neo4j</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Spring Data Neo4J Core</name>
|
<name>Spring Data Neo4J Core</name>
|
||||||
<description><![CDATA[Spring Data Graph core support for Neo4j graph database, offering object graph mapping, a Neo4jTemplate and Spring-Data-Commons Repository implementations.
|
<description><![CDATA[Spring Data Neo4j core support for Neo4j graph database, offering object graph mapping, a Neo4jTemplate and Spring-Data-Commons Repository implementations.
|
||||||
]]></description>
|
]]></description>
|
||||||
<url>http://www.springsource.org/spring-data/neo4j</url>
|
<url>http://www.springsource.org/spring-data/neo4j</url>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.data.neo4j.annotation;
|
package org.springframework.data.neo4j.annotation;
|
||||||
|
|
||||||
|
import org.neo4j.graphdb.Direction;
|
||||||
import org.springframework.data.annotation.Reference;
|
import org.springframework.data.annotation.Reference;
|
||||||
import org.springframework.data.neo4j.core.Direction;
|
|
||||||
import org.springframework.data.neo4j.core.NodeBacked;
|
import org.springframework.data.neo4j.core.NodeBacked;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.neo4j.graphdb.Direction;
|
||||||
import org.springframework.data.annotation.Reference;
|
import org.springframework.data.annotation.Reference;
|
||||||
import org.springframework.data.neo4j.core.Direction;
|
|
||||||
import org.springframework.data.neo4j.core.RelationshipBacked;
|
import org.springframework.data.neo4j.core.RelationshipBacked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class DataGraphNamespaceHandler extends NamespaceHandlerSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamedQueriesLocation() {
|
public String getNamedQueriesLocation() {
|
||||||
return "classpath*:META-INF/graph-named-queries.properties";
|
return "classpath*:META-INF/neo4j-named-queries.properties";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2011 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.data.neo4j.core;
|
|
||||||
|
|
||||||
public enum Direction {
|
|
||||||
|
|
||||||
OUTGOING(org.neo4j.graphdb.Direction.OUTGOING), INCOMING(
|
|
||||||
org.neo4j.graphdb.Direction.INCOMING), BOTH(
|
|
||||||
org.neo4j.graphdb.Direction.BOTH);
|
|
||||||
|
|
||||||
private org.neo4j.graphdb.Direction neo4jDirection;
|
|
||||||
|
|
||||||
private Direction( org.neo4j.graphdb.Direction neo4jDirection ) {
|
|
||||||
this.neo4jDirection = neo4jDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public org.neo4j.graphdb.Direction toNeo4jDir() {
|
|
||||||
return this.neo4jDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -114,10 +114,8 @@ public class IndexingPropertyFieldAccessorListenerFactory<S extends PropertyCont
|
|||||||
if (newVal instanceof Number) newVal = ValueContext.numeric((Number) newVal);
|
if (newVal instanceof Number) newVal = ValueContext.numeric((Number) newVal);
|
||||||
|
|
||||||
final T state = graphBacked.getPersistentState();
|
final T state = graphBacked.getPersistentState();
|
||||||
//index.remove(state, indexKey);
|
index.remove(state, indexKey);
|
||||||
if (newVal == null) {
|
if (newVal != null) {
|
||||||
index.remove(state, indexKey);
|
|
||||||
} else {
|
|
||||||
index.add(state, indexKey, newVal);
|
index.add(state, indexKey, newVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class RelationshipInfo {
|
|||||||
public static RelationshipInfo fromField(Field field, RelatedTo annotation, TypeInformation<?> typeInformation) {
|
public static RelationshipInfo fromField(Field field, RelatedTo annotation, TypeInformation<?> typeInformation) {
|
||||||
return new RelationshipInfo(
|
return new RelationshipInfo(
|
||||||
annotation.type().isEmpty() ? field.getName() : annotation.type(),
|
annotation.type().isEmpty() ? field.getName() : annotation.type(),
|
||||||
annotation.direction().toNeo4jDir(),
|
annotation.direction(),
|
||||||
typeInformation,
|
typeInformation,
|
||||||
annotation.elementClass() != NodeBacked.class ? ClassTypeInformation.from(annotation.elementClass()) : null,
|
annotation.elementClass() != NodeBacked.class ? ClassTypeInformation.from(annotation.elementClass()) : null,
|
||||||
true);
|
true);
|
||||||
@@ -87,7 +87,7 @@ public class RelationshipInfo {
|
|||||||
public static RelationshipInfo fromField(Field field, RelatedToVia annotation, TypeInformation<?> typeInformation) {
|
public static RelationshipInfo fromField(Field field, RelatedToVia annotation, TypeInformation<?> typeInformation) {
|
||||||
return new RelationshipInfo(
|
return new RelationshipInfo(
|
||||||
annotation.type().isEmpty() ? field.getName() : annotation.type(),
|
annotation.type().isEmpty() ? field.getName() : annotation.type(),
|
||||||
annotation.direction().toNeo4jDir(),
|
annotation.direction(),
|
||||||
typeInformation,
|
typeInformation,
|
||||||
annotation.elementClass() != RelationshipBacked.class ? ClassTypeInformation.from(annotation.elementClass()) : null,
|
annotation.elementClass() != RelationshipBacked.class ? ClassTypeInformation.from(annotation.elementClass()) : null,
|
||||||
false);
|
false);
|
||||||
|
|||||||
@@ -264,8 +264,7 @@ public class GraphRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
protected Object dispatchQuery(String queryString, Map<String, Object> params, Pageable pageable) {
|
protected Object dispatchQuery(String queryString, Map<String, Object> params, Pageable pageable) {
|
||||||
GraphQueryMethod queryMethod = getQueryMethod();
|
GraphQueryMethod queryMethod = getQueryMethod();
|
||||||
final Class<?> compoundType = queryMethod.getCompoundType();
|
final Class<?> compoundType = queryMethod.getCompoundType();
|
||||||
final QueryMethod.Type queryResultType = queryMethod.getType();
|
if (queryMethod.isPageQuery()) {
|
||||||
if (queryResultType== QueryMethod.Type.PAGING) {
|
|
||||||
return queryPaged(queryString,params,pageable);
|
return queryPaged(queryString,params,pageable);
|
||||||
}
|
}
|
||||||
if (queryMethod.isIterableResult()) {
|
if (queryMethod.isIterableResult()) {
|
||||||
@@ -291,8 +290,7 @@ public class GraphRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
|
|
||||||
protected Object dispatchQuery(String queryString, Map<String, Object> params, Pageable pageable) {
|
protected Object dispatchQuery(String queryString, Map<String, Object> params, Pageable pageable) {
|
||||||
GraphQueryMethod queryMethod = getQueryMethod();
|
GraphQueryMethod queryMethod = getQueryMethod();
|
||||||
final QueryMethod.Type queryResultType = queryMethod.getType();
|
if (queryMethod.isPageQuery()) {
|
||||||
if (queryResultType== QueryMethod.Type.PAGING) {
|
|
||||||
return queryPaged(queryString,params,pageable);
|
return queryPaged(queryString,params,pageable);
|
||||||
}
|
}
|
||||||
if (queryMethod.isIterableResult()) {
|
if (queryMethod.isIterableResult()) {
|
||||||
|
|||||||
@@ -91,4 +91,8 @@ public class NodeEntityStateFactory {
|
|||||||
private void setUp() {
|
private void setUp() {
|
||||||
this.delegatingFieldAccessorFactory = new PartialNodeEntityState.PartialNodeDelegatingFieldAccessorFactory(graphDatabaseContext);
|
this.delegatingFieldAccessorFactory = new PartialNodeEntityState.PartialNodeDelegatingFieldAccessorFactory(graphDatabaseContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GraphDatabaseContext getGraphDatabaseContext() {
|
||||||
|
return graphDatabaseContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:repository="http://www.springframework.org/schema/data/repository"
|
xmlns:repository="http://www.springframework.org/schema/data/repository"
|
||||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||||
|
|
||||||
targetNamespace="http://www.springframework.org/schema/data/graph"
|
targetNamespace="http://www.springframework.org/schema/data/neo4j"
|
||||||
elementFormDefault="qualified"
|
elementFormDefault="qualified"
|
||||||
attributeFormDefault="unqualified">
|
attributeFormDefault="unqualified">
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</xsd:element>
|
</xsd:element>
|
||||||
|
|
||||||
|
|
||||||
<xsd:complexType name="datagraph-repository">
|
<xsd:complexType name="neo4j-repository">
|
||||||
<xsd:complexContent>
|
<xsd:complexContent>
|
||||||
<xsd:extension base="repository:repository">
|
<xsd:extension base="repository:repository">
|
||||||
<xsd:attribute name="graph-database-context-ref" type="graphDatabaseContextRef" default="graphDatabaseContext">
|
<xsd:attribute name="graph-database-context-ref" type="graphDatabaseContextRef" default="graphDatabaseContext">
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<xsd:complexContent>
|
<xsd:complexContent>
|
||||||
<xsd:extension base="repository:repositories">
|
<xsd:extension base="repository:repositories">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="repository" minOccurs="0" maxOccurs="unbounded" type="datagraph-repository"/>
|
<xsd:element name="repository" minOccurs="0" maxOccurs="unbounded" type="neo4j-repository"/>
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="graph-database-context-ref" type="graphDatabaseContextRef"/>
|
<xsd:attribute name="graph-database-context-ref" type="graphDatabaseContextRef"/>
|
||||||
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package org.springframework.data.neo4j;
|
package org.springframework.data.neo4j;
|
||||||
|
|
||||||
|
import org.neo4j.graphdb.Direction;
|
||||||
import org.neo4j.graphdb.DynamicRelationshipType;
|
import org.neo4j.graphdb.DynamicRelationshipType;
|
||||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||||
import org.neo4j.kernel.Traversal;
|
import org.neo4j.kernel.Traversal;
|
||||||
import org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl;
|
import org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl;
|
||||||
import org.springframework.data.neo4j.annotation.*;
|
import org.springframework.data.neo4j.annotation.*;
|
||||||
import org.springframework.data.neo4j.core.Direction;
|
|
||||||
import org.springframework.data.neo4j.core.FieldTraversalDescriptionBuilder;
|
import org.springframework.data.neo4j.core.FieldTraversalDescriptionBuilder;
|
||||||
import org.springframework.data.neo4j.core.NodeBacked;
|
import org.springframework.data.neo4j.core.NodeBacked;
|
||||||
import org.springframework.data.neo4j.mapping.Neo4JPersistentProperty;
|
import org.springframework.data.neo4j.mapping.Neo4JPersistentProperty;
|
||||||
@@ -47,6 +47,10 @@ public class Group {
|
|||||||
@Indexed
|
@Indexed
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@GraphProperty
|
||||||
|
@Indexed
|
||||||
|
private Boolean admin;
|
||||||
|
|
||||||
@GraphProperty
|
@GraphProperty
|
||||||
private String unindexedName;
|
private String unindexedName;
|
||||||
|
|
||||||
@@ -149,4 +153,12 @@ public class Group {
|
|||||||
public void setIndexLevelName(String indexLevelName) {
|
public void setIndexLevelName(String indexLevelName) {
|
||||||
this.indexLevelName = indexLevelName;
|
this.indexLevelName = indexLevelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean isAdmin() {
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdmin(Boolean admin) {
|
||||||
|
this.admin = admin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import javax.validation.constraints.Max;
|
|||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
import org.neo4j.graphdb.Direction;
|
||||||
import org.springframework.data.neo4j.annotation.GraphId;
|
import org.springframework.data.neo4j.annotation.GraphId;
|
||||||
import org.springframework.data.neo4j.annotation.Indexed;
|
import org.springframework.data.neo4j.annotation.Indexed;
|
||||||
import org.springframework.data.neo4j.annotation.NodeEntity;
|
import org.springframework.data.neo4j.annotation.NodeEntity;
|
||||||
import org.springframework.data.neo4j.annotation.Query;
|
import org.springframework.data.neo4j.annotation.Query;
|
||||||
import org.springframework.data.neo4j.annotation.RelatedTo;
|
import org.springframework.data.neo4j.annotation.RelatedTo;
|
||||||
import org.springframework.data.neo4j.annotation.RelatedToVia;
|
import org.springframework.data.neo4j.annotation.RelatedToVia;
|
||||||
import org.springframework.data.neo4j.core.Direction;
|
|
||||||
import org.springframework.data.neo4j.fieldaccess.DynamicProperties;
|
import org.springframework.data.neo4j.fieldaccess.DynamicProperties;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.neo4j.graphdb.Direction;
|
||||||
import org.springframework.data.neo4j.annotation.Indexed;
|
import org.springframework.data.neo4j.annotation.Indexed;
|
||||||
import org.springframework.data.neo4j.annotation.NodeEntity;
|
import org.springframework.data.neo4j.annotation.NodeEntity;
|
||||||
import org.springframework.data.neo4j.annotation.RelatedTo;
|
import org.springframework.data.neo4j.annotation.RelatedTo;
|
||||||
import org.springframework.data.neo4j.core.Direction;
|
|
||||||
import org.springframework.data.neo4j.mapping.Neo4JMappingContext;
|
import org.springframework.data.neo4j.mapping.Neo4JMappingContext;
|
||||||
import org.springframework.data.repository.query.parser.Property;
|
import org.springframework.data.repository.query.parser.Property;
|
||||||
|
|
||||||
|
|||||||
@@ -349,4 +349,14 @@ public class IndexTest {
|
|||||||
relationshipIndex.add(indexedRelationship, NAME, NAME_VALUE);
|
relationshipIndex.add(indexedRelationship, NAME, NAME_VALUE);
|
||||||
Assert.assertEquals("indexed relationship found", indexedRelationship, relationshipIndex.get(NAME, NAME_VALUE).next());
|
Assert.assertEquals("indexed relationship found", indexedRelationship, relationshipIndex.get(NAME, NAME_VALUE).next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Transactional
|
||||||
|
public void testUpdateBooleanPropertyIsReflectedInIndex() {
|
||||||
|
Group group = new Group().persist();
|
||||||
|
group.setAdmin(true);
|
||||||
|
assertEquals(1,IteratorUtil.asCollection(groupRepository.findAllByPropertyValue("admin",true)).size());
|
||||||
|
group.setAdmin(false);
|
||||||
|
assertEquals(0,IteratorUtil.asCollection(groupRepository.findAllByPropertyValue("admin",true)).size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ ant -f src/ant/upload-dist.xml \
|
|||||||
-Ddist.accessKey=<access key> \
|
-Ddist.accessKey=<access key> \
|
||||||
-Ddist.secretKey=<secret key> \
|
-Ddist.secretKey=<secret key> \
|
||||||
-Ddist.bucketName=dist.springframework.org \
|
-Ddist.bucketName=dist.springframework.org \
|
||||||
-Ddist.fileName=spring-data-graph-1.0.0.???.zip \
|
-Ddist.fileName=spring-data-neo4j-1.0.0.???.zip \
|
||||||
-Ddist.filePath=../../spring-data-graph-1.0.0.???.zip \
|
-Ddist.filePath=../../spring-data-neo4j-1.0.0.???.zip \
|
||||||
-Ddist.version=1.0.0.??? \
|
-Ddist.version=1.0.0.??? \
|
||||||
upload-dist
|
upload-dist
|
||||||
-->
|
-->
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
<bookinfo>
|
<bookinfo>
|
||||||
<title>Good Relationships</title>
|
<title>Good Relationships</title>
|
||||||
<subtitle>The Spring Data Graph Guide Book</subtitle>
|
<subtitle>The Spring Data Neo4j Guide Book</subtitle>
|
||||||
<releaseinfo>&version;</releaseinfo>
|
<releaseinfo>&version;</releaseinfo>
|
||||||
<date/>
|
<date/>
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The first part of the book provides a tutorial that walks through the creation of a complete web
|
The first part of the book provides a tutorial that walks through the creation of a complete web
|
||||||
application called cineasts.net, built with Spring Data Graph and Neo4j.
|
application called cineasts.net, built with Spring Data Neo4j.
|
||||||
Cineasts are people who love movies, and the site is a gathering place for moviegoers. For
|
Cineasts are people who love movies, and the site is a gathering place for moviegoers. For
|
||||||
cineasts.net we decided to add a social aspect to the rating of movies, allowing friends to
|
cineasts.net we decided to add a social aspect to the rating of movies, allowing friends to
|
||||||
share their scores and get recommendations for new friends and movies.
|
share their scores and get recommendations for new friends and movies.
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
<para>
|
<para>
|
||||||
The tutorial takes the reader through the steps necessary to create the application.
|
The tutorial takes the reader through the steps necessary to create the application.
|
||||||
It provides the configuration and code examples that are needed to understand what's
|
It provides the configuration and code examples that are needed to understand what's
|
||||||
happening in Spring Data Graph. The complete source code for the app is available on
|
happening in Spring Data Neo4j. The complete source code for the app is available on
|
||||||
<ulink url="http://github.com/jexp/cineasts">Github</ulink>.
|
<ulink url="http://github.com/jexp/cineasts">Github</ulink>.
|
||||||
</para>
|
</para>
|
||||||
</partintro>
|
</partintro>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<xi:include href="tutorial/setup.xml"/>
|
<xi:include href="tutorial/setup.xml"/>
|
||||||
<xi:include href="tutorial/domain.xml"/>
|
<xi:include href="tutorial/domain.xml"/>
|
||||||
<xi:include href="tutorial/neo4j.xml"/>
|
<xi:include href="tutorial/neo4j.xml"/>
|
||||||
<xi:include href="tutorial/spring-data-graph.xml"/>
|
<xi:include href="tutorial/spring-data-neo4j.xml"/>
|
||||||
<xi:include href="tutorial/annotations.xml"/>
|
<xi:include href="tutorial/annotations.xml"/>
|
||||||
<xi:include href="tutorial/indexing.xml"/>
|
<xi:include href="tutorial/indexing.xml"/>
|
||||||
<xi:include href="tutorial/repository.xml"/>
|
<xi:include href="tutorial/repository.xml"/>
|
||||||
@@ -107,15 +107,15 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
This part of the Spring Data Graph Guide book provides the reference documentation. It details many
|
This part of the Spring Data Neo4j Guide book provides the reference documentation. It details many
|
||||||
aspects of the tutorial and also explains concepts that were only just mentioned there.
|
aspects of the tutorial and also explains concepts that were only just mentioned there.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Its content covers information about the programming model, APIs, concepts, annotations and
|
Its content covers information about the programming model, APIs, concepts, annotations and
|
||||||
technical details of Spring Data Graph.
|
technical details of Spring Data Neo4j.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Whenever you look for the means to employ the full power of the Spring Data Graph library you find your
|
Whenever you look for the means to employ the full power of the Spring Data Neo4j library you find your
|
||||||
answers in the reference section. If you don't, please inform us about missing or incorrect content so that
|
answers in the reference section. If you don't, please inform us about missing or incorrect content so that
|
||||||
we can fix that.
|
we can fix that.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
<preface>
|
<preface>
|
||||||
<title>About this guide book</title>
|
<title>About this guide book</title>
|
||||||
<section>
|
<section>
|
||||||
<title>The Spring Data Graph Project</title>
|
<title>The Spring Data Neo4j Project</title>
|
||||||
<para>
|
<para>
|
||||||
Welcome to the Spring Data Graph Guide Book. Thank you for taking the time to get an in depth look
|
Welcome to the Spring Data Neo4j Guide Book. Thank you for taking the time to get an in depth look
|
||||||
into <ulink url="https://github.com/SpringSource/spring-data-graph">Spring Data Graph</ulink>.
|
into <ulink url="https://github.com/SpringSource/spring-data-neo4j">Spring Data Neo4j</ulink>.
|
||||||
This project is part of the <ulink url="http://springsource.org/spring-data">Spring Data project</ulink>,
|
This project is part of the <ulink url="http://springsource.org/spring-data">Spring Data project</ulink>,
|
||||||
which brings the convenient programming model of the Spring Framework to modern NOSQL databases.
|
which brings the convenient programming model of the Spring Framework to modern NOSQL databases.
|
||||||
Spring Data Graph, as the name alludes to, aims to provide support for graph databases. It currently
|
Spring Data Neo4j, as the name alludes to, aims to provide support for graph databases. It currently
|
||||||
supports <ulink url="http://neo4j.org">Neo4j</ulink>.
|
supports <ulink url="http://neo4j.org">Neo4j</ulink>.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@@ -21,10 +21,10 @@
|
|||||||
by our peers.
|
by our peers.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you have any feedback on Spring Data Graph or this book, please provide it via the
|
If you have any feedback on Spring Data Neo4j or this book, please provide it via the
|
||||||
<ulink url="https://jira.springsource.org/browse/DATAGRAPH">SpringSource JIRA</ulink>, the
|
<ulink url="http://jira.springsource.org/browse/DATAGRAPH">SpringSource JIRA</ulink>, the
|
||||||
<ulink url="http://forum.springsource.org/forumdisplay.php?f=80">SpringSource NOSQL Forum</ulink>,
|
<ulink url="http://forum.springsource.org/forumdisplay.php?f=80">SpringSource NOSQL Forum</ulink>,
|
||||||
<ulink url="https://github.com/SpringSource/spring-data-graph/issues">github comments or issues</ulink>,
|
<ulink url="http://github.com/SpringSource/spring-data-neo4j/issues">github comments or issues</ulink>,
|
||||||
or the <ulink url="http://neo4j.org/community/list/">Neo4j mailing list</ulink>.
|
or the <ulink url="http://neo4j.org/community/list/">Neo4j mailing list</ulink>.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<para>
|
<para>
|
||||||
We chose a tutorial describing the creation of a web application that allows movie enthusiasts to
|
We chose a tutorial describing the creation of a web application that allows movie enthusiasts to
|
||||||
find their favorite movies, rate them, connect with fellow movie geeks, and enjoy social features such as
|
find their favorite movies, rate them, connect with fellow movie geeks, and enjoy social features such as
|
||||||
recommendations. The application is running on Neo4j using Spring Data Graph and the well-known Spring
|
recommendations. The application is running on Neo4j using Spring Data Neo4j and the well-known Spring
|
||||||
Web Stack.
|
Web Stack.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
the library. It discusses the programming model, the underlying assumptions, and internals, as well as the
|
the library. It discusses the programming model, the underlying assumptions, and internals, as well as the
|
||||||
APIs for the object-graph mapping. The reference documentation is typically used to look up concrete bits of
|
APIs for the object-graph mapping. The reference documentation is typically used to look up concrete bits of
|
||||||
information, or to drill down into certain topics. For hackers wanting to really delve into Spring Data
|
information, or to drill down into certain topics. For hackers wanting to really delve into Spring Data
|
||||||
Graph, it can of course also be read cover-to-cover.
|
Neo4j, it can of course also be read cover-to-cover.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section><title>Acknowledgements</title>
|
<section><title>Acknowledgements</title>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<para>
|
<para>
|
||||||
We also appreciate very much the foresight of Rod Johnson and Emil Eifrem to initiate the project, and now
|
We also appreciate very much the foresight of Rod Johnson and Emil Eifrem to initiate the project, and now
|
||||||
also providing great forewords. Their leadership inspired collaboration between the engineering teams at
|
also providing great forewords. Their leadership inspired collaboration between the engineering teams at
|
||||||
SpringSource and Neo Technology, a tremendous help during the making of Spring Data Graph.
|
SpringSource and Neo Technology, a tremendous help during the making of Spring Data Neo4j.
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,16 @@
|
|||||||
"Spring is the most popular middleware on the planet," I thought to myself as I walked up to Rod Johnson in late 2009 at the JAOO conference in Aarhus, Denmark. Rod had just given an introductory presentation about Spring Roo and when he was done I told him "Great talk. You're clearly building a stack for the future. What about support for non-relational databases?"
|
"Spring is the most popular middleware on the planet," I thought to myself as I walked up to Rod Johnson in late 2009 at the JAOO conference in Aarhus, Denmark. Rod had just given an introductory presentation about Spring Roo and when he was done I told him "Great talk. You're clearly building a stack for the future. What about support for non-relational databases?"
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
We started talking and quickly agreed that NOSQL will play an important role in emerging stacks. Now, a year and half later, Spring Data Graph is available in its first stable release and I'm blown away by the result. Never before in any environment, in any programming framework, in any stack, has it been so easy and intuitive to tap into the power of a graph database like Neo4j. It's a testament to the efforts by an awesome team of four hackers from Neo Technology and VMware: Michael Hunger, David Montag, Thomas Risberg and Mark Pollack.
|
We started talking and quickly agreed that NOSQL will play an important role in emerging stacks. Now, a year and half later, Spring Data Neo4j is available in its first stable release and I'm blown away by the result. Never before in any environment, in any programming framework, in any stack, has it been so easy and intuitive to tap into the power of a graph database like Neo4j. It's a testament to the efforts by an awesome team of four hackers from Neo Technology and VMware: Michael Hunger, David Montag, Thomas Risberg and Mark Pollack.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The Spring framework revolutionized how we all wrote enterprise Java applications and today it's used by millions of enterprise developers. Graph databases also stand out in the NOSQL crowd when it comes to enterprise adoption. You can find graph databases used in areas as diverse as network management, fraud detection, cloud management, anything with social data, geo and location services, master data management, bioinformatics, configuration databases, and much more.
|
The Spring framework revolutionized how we all wrote enterprise Java applications and today it's used by millions of enterprise developers. Graph databases also stand out in the NOSQL crowd when it comes to enterprise adoption. You can find graph databases used in areas as diverse as network management, fraud detection, cloud management, anything with social data, geo and location services, master data management, bioinformatics, configuration databases, and much more.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring developers deserve access to the best tools available to solve their problem. Sometimes that's a relational database accessed through JPA. But more often than not, a graph database like Neo4j is the perfect fit for your project. I hope that Spring Data Graph will give you access to the power and flexibility of graph databases while retaining the familiar productivity and convenience of the Spring framework.
|
Spring developers deserve access to the best tools available to solve their problem. Sometimes that's a relational database accessed through JPA. But more often than not, a graph database like Neo4j is the perfect fit for your project. I hope that Spring Data Neo4j will give you access to the power and flexibility of graph databases while retaining the familiar productivity and convenience of the Spring framework.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Enjoy the Spring Data Graph guide book and welcome to the wonderful world of graph databases!
|
Enjoy the Spring Data Neo4j guide book and welcome to the wonderful world of graph databases!
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Emil Eifrem, CEO of Neo Technology
|
Emil Eifrem, CEO of Neo Technology
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<preface>
|
<preface>
|
||||||
<title>Foreword by Rod Johnson</title>
|
<title>Foreword by Rod Johnson</title>
|
||||||
<para>
|
<para>
|
||||||
I’m excited about Spring Data Graph for several reasons.
|
I’m excited about Spring Data Neo4j for several reasons.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
First, this project is in a very important space. We are in an era of transition. A very few years ago, a
|
First, this project is in a very important space. We are in an era of transition. A very few years ago, a
|
||||||
@@ -14,31 +14,31 @@
|
|||||||
valuable in many applications. It's a choice you should add to your toolbox.
|
valuable in many applications. It's a choice you should add to your toolbox.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Second, Spring Data Graph is an innovative project, which makes it easy to work with one of the most interesting
|
Second, Spring Data Neo4j is an innovative project, which makes it easy to work with one of the most interesting
|
||||||
new data stores. Unfortunately, the proliferation of new data stores has not been matched by innovation in
|
new data stores. Unfortunately, the proliferation of new data stores has not been matched by innovation in
|
||||||
programming models to work with them. Ironically, just after modern ORM mapping made working with relational
|
programming models to work with them. Ironically, just after modern ORM mapping made working with relational
|
||||||
data in Java relatively easy, the data store disruption occurred, and developers were back to square one:
|
data in Java relatively easy, the data store disruption occurred, and developers were back to square one:
|
||||||
struggling once more with clumsy, low level APIs. Working with most non-relational technologies is overly
|
struggling once more with clumsy, low level APIs. Working with most non-relational technologies is overly
|
||||||
complex and imposes too much work on developers. Spring Data Graph makes working with Neo4j amazingly easy, and
|
complex and imposes too much work on developers. Spring Data Neo4j makes working with Neo4j amazingly easy, and
|
||||||
therefore has the potential to make you more successful as a developer. Its use of AspectJ to eliminate
|
therefore has the potential to make you more successful as a developer. Its use of AspectJ to eliminate
|
||||||
persistence code from your domain model is truly innovative, and on the cutting edge of today’s Java
|
persistence code from your domain model is truly innovative, and on the cutting edge of today’s Java
|
||||||
technologies.
|
technologies.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Third, I'm excited about Spring Data Graph for personal reasons. I no longer get to write code as often as I
|
Third, I'm excited about Spring Data Neo4j for personal reasons. I no longer get to write code as often as I
|
||||||
would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4j
|
would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4j
|
||||||
dramatically easier and cross-store object navigation possible gave me an excuse for a much-needed coding binge
|
dramatically easier and cross-store object navigation possible gave me an excuse for a much-needed coding binge
|
||||||
early in 2010. This led to a prototype of what became Spring Data Graph — at times written paired with Emil. I’m
|
early in 2010. This led to a prototype of what became Spring Data Neo4j — at times written paired with Emil. I’m
|
||||||
sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren't
|
sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren't
|
||||||
rusty — thanks Michael and Thomas! — but I retain my pleasant memories.
|
rusty — thanks Michael and Thomas! — but I retain my pleasant memories.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Finally, Spring Data Graph is part of the broader Spring Data project: one of the key areas in which Spring is
|
Finally, Spring Data Neo4j is part of the broader Spring Data project: one of the key areas in which Spring is
|
||||||
innovating to help meet new application requirements. I encourage you to explore Spring Data, and — better
|
innovating to help meet new application requirements. I encourage you to explore Spring Data, and — better
|
||||||
still — become involved in the community and contribute.
|
still — become involved in the community and contribute.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Enjoy the Spring Data Graph book, and happy coding!
|
Enjoy the Spring Data Neo4j book, and happy coding!
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Rod Johnson, Founder, Spring and SVP, Application Platform, VMware
|
Rod Johnson, Founder, Spring and SVP, Application Platform, VMware
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<chapter id="reference:aspectj-details">
|
<chapter id="reference:aspectj-details">
|
||||||
<title>AspectJ details</title>
|
<title>AspectJ details</title>
|
||||||
<para>
|
<para>
|
||||||
The object graph mapper of Spring Data Graph relies heavily on AspectJ. AspectJ is a Java implementation
|
The object graph mapper of Spring Data Neo4j relies heavily on AspectJ. AspectJ is a Java implementation
|
||||||
of the <ulink url="https://secure.wikimedia.org/wikipedia/en/wiki/Aspect-oriented_programming">aspect-oriented
|
of the <ulink url="https://secure.wikimedia.org/wikipedia/en/wiki/Aspect-oriented_programming">aspect-oriented
|
||||||
programming</ulink> paradigm that allows easy extraction and controlled application of so-called
|
programming</ulink> paradigm that allows easy extraction and controlled application of so-called
|
||||||
cross-cutting concerns. Cross-cutting concerns are typically repetitive tasks in a system (e.g. logging,
|
cross-cutting concerns. Cross-cutting concerns are typically repetitive tasks in a system (e.g. logging,
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
limited, potentially adding quite a number of configuration options or parameters.
|
limited, potentially adding quite a number of configuration options or parameters.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The AspectJ pointcut language can be intimidating, but a developer using Spring Data Graph will not have
|
The AspectJ pointcut language can be intimidating, but a developer using Spring Data Neo4j will not have
|
||||||
to deal with that. Users don't have care about to hooking into a framework mechanism, or having to extend
|
to deal with that. Users don't have care about to hooking into a framework mechanism, or having to extend
|
||||||
a framework superclass.
|
a framework superclass.
|
||||||
</para>
|
</para>
|
||||||
@@ -26,14 +26,14 @@
|
|||||||
existing classes.
|
existing classes.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph uses a mix of these mechanisms internally. First, when encountering the
|
Spring Data Neo4j uses a mix of these mechanisms internally. First, when encountering the
|
||||||
<code>@NodeEntity</code> or <code>@RelationshipEntity</code> annotations it introduces a new interface
|
<code>@NodeEntity</code> or <code>@RelationshipEntity</code> annotations it introduces a new interface
|
||||||
<code>NodeBacked</code> or <code>RelationshipBacked</code> to the annotated class. Secondly, it introduces
|
<code>NodeBacked</code> or <code>RelationshipBacked</code> to the annotated class. Secondly, it introduces
|
||||||
fields and methods to the annotated class. See <xref linkend="reference:programming-model:introduced-methods"/>
|
fields and methods to the annotated class. See <xref linkend="reference:programming-model:introduced-methods"/>
|
||||||
for more information on the methods introduced.
|
for more information on the methods introduced.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph also leverages AspectJ to intercept access to fields, delegating the calls to the graph
|
Spring Data Neo4j also leverages AspectJ to intercept access to fields, delegating the calls to the graph
|
||||||
database instead. Under the hood, properties and relationships will be created.
|
database instead. Under the hood, properties and relationships will be created.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -52,6 +52,6 @@
|
|||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
AspectJ also supports other types of weaving, e.g. load-time weaving and runtime weaving. These are
|
AspectJ also supports other types of weaving, e.g. load-time weaving and runtime weaving. These are
|
||||||
currently not supported by Spring Data Graph.
|
currently not supported by Spring Data Neo4j.
|
||||||
</para>
|
</para>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<chapter id="reference:cross-store">
|
<chapter id="reference:cross-store">
|
||||||
<title>Cross-store persistence</title>
|
<title>Cross-store persistence</title>
|
||||||
<para>
|
<para>
|
||||||
The Spring Data Graph project support cross-store persistence, which allows for parts of the data to be
|
The Spring Data Neo4j project support cross-store persistence, which allows for parts of the data to be
|
||||||
stored in a traditional JPA data store (RDBMS), and other parts in a graph store. This means that an entity
|
stored in a traditional JPA data store (RDBMS), and other parts in a graph store. This means that an entity
|
||||||
can be partially stored in e.g. MySQL, and partially stored in Neo4j.
|
can be partially stored in e.g. MySQL, and partially stored in Neo4j.
|
||||||
</para>
|
</para>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Partial entities</title>
|
<title>Partial entities</title>
|
||||||
<para>
|
<para>
|
||||||
Partial graph persistence is achieved by restricting the Spring Data Graph aspects to manage only
|
Partial graph persistence is achieved by restricting the Spring Data Neo4j aspects to manage only
|
||||||
explicitly annotated parts of the entity. Those fields will be made <code>@Transient</code> by the
|
explicitly annotated parts of the entity. Those fields will be made <code>@Transient</code> by the
|
||||||
aspect so that JPA ignores them.
|
aspect so that JPA ignores them.
|
||||||
</para>
|
</para>
|
||||||
@@ -37,8 +37,8 @@
|
|||||||
can then be found using the indexing facilities, and the two entities can be reassociated.
|
can then be found using the indexing facilities, and the two entities can be reassociated.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Using these mechanisms and the Spring Data Graph aspects, a single POJO can contain some fields
|
Using these mechanisms and the Spring Data Neo4j aspects, a single POJO can contain some fields
|
||||||
handled by JPA and others handles by Spring Data Graph. This also includes relationship fields persisted
|
handled by JPA and others handles by Spring Data Neo4j. This also includes relationship fields persisted
|
||||||
in the graph database.
|
in the graph database.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@@ -52,20 +52,20 @@
|
|||||||
<title>@NodeEntity(partial = "true")</title>
|
<title>@NodeEntity(partial = "true")</title>
|
||||||
<para>
|
<para>
|
||||||
When annotating an entity with <code>partial = true</code>, this marks it as a cross-store entity.
|
When annotating an entity with <code>partial = true</code>, this marks it as a cross-store entity.
|
||||||
Spring Data Graph will thus only manage fields explicitly annotated with <code>@GraphProperty</code>.
|
Spring Data Neo4j will thus only manage fields explicitly annotated with <code>@GraphProperty</code>.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<title>@GraphProperty</title>
|
<title>@GraphProperty</title>
|
||||||
<para>
|
<para>
|
||||||
Fields of primitive or convertible types do not normally have to be annotated in order to be
|
Fields of primitive or convertible types do not normally have to be annotated in order to be
|
||||||
persisted by Spring Data Graph. In cross-store mode, Spring Data Graph <emphasis>only</emphasis>
|
persisted by Spring Data Neo4j. In cross-store mode, Spring Data Neo4j <emphasis>only</emphasis>
|
||||||
persists fields explicitly annotated with <code>@GraphProperty</code>. JPA will ignore these fields.
|
persists fields explicitly annotated with <code>@GraphProperty</code>. JPA will ignore these fields.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<para>
|
<para>
|
||||||
The following example is taken from the
|
The following example is taken from the
|
||||||
<ulink url="http://github.com/SpringSource/spring-data-graph-examples">Spring Data Graph examples</ulink>
|
<ulink url="http://github.com/SpringSource/spring-data-neo4j-examples">Spring Data Neo4j examples</ulink>
|
||||||
myrestaurants-social project:
|
myrestaurants-social project:
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -119,28 +119,28 @@ public class UserAccount {
|
|||||||
<section>
|
<section>
|
||||||
<title>Configuring cross-store persistence</title>
|
<title>Configuring cross-store persistence</title>
|
||||||
<para>
|
<para>
|
||||||
Configuring cross-store persistence is done similarly to the default Spring Data Graph configuration.
|
Configuring cross-store persistence is done similarly to the default Spring Data Neo4j configuration.
|
||||||
All you need to do is to specify an <code>entityManagerFactory</code> in the XML namespace
|
All you need to do is to specify an <code>entityManagerFactory</code> in the XML namespace
|
||||||
<code>config</code> element, and Spring Data Graph will configure itself for cross-store use.
|
<code>config</code> element, and Spring Data Neo4j will configure itself for cross-store use.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Cross-store Spring configuration</title>
|
<title>Cross-store Spring configuration</title>
|
||||||
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
|
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:datagraph="http://www.springframework.org/schema/data/graph"
|
xmlns:datagraph="http://www.springframework.org/schema/data/neo4j"
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||||
http://www.springframework.org/schema/data/graph
|
http://www.springframework.org/schema/data/neo4j
|
||||||
http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd
|
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
|
||||||
">
|
">
|
||||||
|
|
||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
|
|
||||||
<datagraph:config storeDirectory="target/config-test"
|
<neo4j:config storeDirectory="target/config-test"
|
||||||
entityManagerFactory="entityManagerFactory"/>
|
entityManagerFactory="entityManagerFactory"/>
|
||||||
|
|
||||||
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<title>Neo4j Server</title>
|
<title>Neo4j Server</title>
|
||||||
<para>
|
<para>
|
||||||
Neo4j is not only available in embedded mode. It can also be installed and run as a stand-alone server
|
Neo4j is not only available in embedded mode. It can also be installed and run as a stand-alone server
|
||||||
accessible via a REST API. Developers can integrate Spring Data Graph into the Neo4j server infrastructure
|
accessible via a REST API. Developers can integrate Spring Data Neo4j into the Neo4j server infrastructure
|
||||||
in two ways: in an unmanaged server extension, or via the REST API.
|
in two ways: in an unmanaged server extension, or via the REST API.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
<programlisting language="ini"><![CDATA[org.neo4j.server.thirdparty_jaxrs_classes=com.example.mypackage=/my-context]]></programlisting>
|
<programlisting language="ini"><![CDATA[org.neo4j.server.thirdparty_jaxrs_classes=com.example.mypackage=/my-context]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Running Spring Data Graph on the Neo4j Server is easy. You need to tell the server where to find the
|
Running Spring Data Neo4j on the Neo4j Server is easy. You need to tell the server where to find the
|
||||||
Spring context configuration file, and which beans from it to expose:
|
Spring context configuration file, and which beans from it to expose:
|
||||||
<example>
|
<example>
|
||||||
<title>Server plugin initialization</title>
|
<title>Server plugin initialization</title>
|
||||||
@@ -74,23 +74,23 @@ public void foo( @Context WorldRepository repo ) {
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<title>Using Spring Data Graph as a REST client</title>
|
<title>Using Spring Data Neo4j as a REST client</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph can use a set of Java REST bindings which come as a drop in replacement for the
|
Spring Data Neo4j can use a set of Java REST bindings which come as a drop in replacement for the
|
||||||
GraphDatabaseService API. By simply configuring the <code>graphDatabaseService</code> to be a
|
GraphDatabaseService API. By simply configuring the <code>graphDatabaseService</code> to be a
|
||||||
<code>RestGraphDatabase</code> pointing to a Neo4j Server instance.
|
<code>RestGraphDatabase</code> pointing to a Neo4j Server instance.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
The Neo4j Server REST API does not allow for transactions to span across requests, which means
|
The Neo4j Server REST API does not allow for transactions to span across requests, which means
|
||||||
that Spring Data Graph is not transactional when running with a <code>RestGraphDatabase</code>.
|
that Spring Data Neo4j is not transactional when running with a <code>RestGraphDatabase</code>.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
Please also keep in mind that performing graph operations via the REST-API is about one order of
|
Please also keep in mind that performing graph operations via the REST-API is about one order of
|
||||||
magnitude slower than location operations. Try to use the Neo4j Cypher query language,
|
magnitude slower than location operations. Try to use the Neo4j Cypher query language,
|
||||||
server-side traversals (<code>RestTraversal</code>) or Gremlin expressions whenever possible for retrieving large sets of data.
|
server-side traversals (<code>RestTraversal</code>) or Gremlin expressions whenever possible for retrieving large sets of data.
|
||||||
Future versions of Spring Data Graph will use the more performant batching as well as a binary protocol.
|
Future versions of Spring Data Neo4j will use the more performant batching as well as a binary protocol.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
To set up your project to use the REST bindings, add this dependency to your pom.xml:
|
To set up your project to use the REST bindings, add this dependency to your pom.xml:
|
||||||
@@ -104,11 +104,11 @@ public void foo( @Context WorldRepository repo ) {
|
|||||||
</dependency>
|
</dependency>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
Now, you set up the normal Spring Data Graph configuration, but point the database to an URL instead
|
Now, you set up the normal Spring Data Neo4j configuration, but point the database to an URL instead
|
||||||
of a local directory, like so:
|
of a local directory, like so:
|
||||||
<example>
|
<example>
|
||||||
<title>REST client configuration - application context</title>
|
<title>REST client configuration - application context</title>
|
||||||
<programlisting language="xml"><![CDATA[<datagraph:config graphDatabaseService="graphDatabaseService"/>
|
<programlisting language="xml"><![CDATA[<neo4j:config graphDatabaseService="graphDatabaseService"/>
|
||||||
|
|
||||||
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.RestGraphDatabase">
|
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.RestGraphDatabase">
|
||||||
<constructor-arg value="http://localhost:7474/db/data/"/>
|
<constructor-arg value="http://localhost:7474/db/data/"/>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ for (Path position : traversalDescription.traverse(myStartNode)) {
|
|||||||
Retrieval is done with query methods on indexes, returning an IndexHits iterator.
|
Retrieval is done with query methods on indexes, returning an IndexHits iterator.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph provides automatic indexing via the @Indexed annotation, eliminating the need
|
Spring Data Neo4j provides automatic indexing via the @Indexed annotation, eliminating the need
|
||||||
for manual index management.
|
for manual index management.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
@@ -176,9 +176,9 @@ for (Node foundNode : nodeIndex.get("property","value")) {
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Cypher can be executed on an embedded graph db using <code>ExecutionEngine</code> and
|
Cypher can be executed on an embedded graph db using <code>ExecutionEngine</code> and
|
||||||
<code>CypherParser</code>. This is encapsulated in Spring Data Graph with
|
<code>CypherParser</code>. This is encapsulated in Spring Data Neo4j with
|
||||||
<code>CypherQueryEngine</code>. The Neo4j-REST-Server comes with a Cypher-Plugin that is accessible remotely and is
|
<code>CypherQueryEngine</code>. The Neo4j-REST-Server comes with a Cypher-Plugin that is accessible remotely and is
|
||||||
available in the Spring Data Graph REST-Binding.
|
available in the Spring Data Neo4j REST-Binding.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Cypher Examples on the Cineasts.net Dataset</title>
|
<title>Cypher Examples on the Cineasts.net Dataset</title>
|
||||||
@@ -218,9 +218,9 @@ start user=(User,login,'micha') match (user)-[:FRIEND]-(friend)-[r,:RATED]->(mov
|
|||||||
turing complete.
|
turing complete.
|
||||||
</para>
|
</para>
|
||||||
<para>Gremlin can be executed by including the tinkerpop and blueprints dependencies and then requesting a <code>ScriptEngine</code>
|
<para>Gremlin can be executed by including the tinkerpop and blueprints dependencies and then requesting a <code>ScriptEngine</code>
|
||||||
of type "gremlin" from the <code>javax.Script*</code> facilities. In Spring Data Graph this is encapsulated in
|
of type "gremlin" from the <code>javax.Script*</code> facilities. In Spring Data Neo4j this is encapsulated in
|
||||||
<code>GremlinQueryEngine</code>. The Neo4j-REST-Server also comes with a Gremlin-Plugin that is accessible remotely and is
|
<code>GremlinQueryEngine</code>. The Neo4j-REST-Server also comes with a Gremlin-Plugin that is accessible remotely and is
|
||||||
available in the Spring Data Graph REST-Binding.
|
available in the Spring Data Neo4j REST-Binding.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Sample Gremlin Queries</title>
|
<title>Sample Gremlin Queries</title>
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
<para>
|
<para>
|
||||||
Although adding layers of abstraction is a common pattern in software development, each of these layers
|
Although adding layers of abstraction is a common pattern in software development, each of these layers
|
||||||
generally adds overhead and performance penalties. This chapter discusses the performance implications
|
generally adds overhead and performance penalties. This chapter discusses the performance implications
|
||||||
of using Spring Data Graph instead of the Neo4j API directly.
|
of using Spring Data Neo4j instead of the Neo4j API directly.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section>
|
||||||
<title>When is Spring Data Graph right</title>
|
<title>When is Spring Data Neo4j right</title>
|
||||||
<para>
|
<para>
|
||||||
The focus of Spring Data Graph is to add a convenience layer on top of the Neo4j API. This enables
|
The focus of Spring Data Neo4j is to add a convenience layer on top of the Neo4j API. This enables
|
||||||
developers to get up and running with a graph database very quickly, having their domain objects
|
developers to get up and running with a graph database very quickly, having their domain objects
|
||||||
mapped to the graph with very little work. Building on this foundation, one can later explore other,
|
mapped to the graph with very little work. Building on this foundation, one can later explore other,
|
||||||
more efficient ways to explore and process the graph - if the performance requirements demand it.
|
more efficient ways to explore and process the graph - if the performance requirements demand it.
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
frameworks and libraries that expect Java POJOs as input or create them as results.
|
frameworks and libraries that expect Java POJOs as input or create them as results.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph, however, was not designed with a major focus on performance. It does add some overhead
|
Spring Data Neo4j, however, was not designed with a major focus on performance. It does add some overhead
|
||||||
to pure graph operations. Something to keep in mind is that any access of properties and relationships
|
to pure graph operations. Something to keep in mind is that any access of properties and relationships
|
||||||
will in general read through down to the database. To avoid multiple reads, it is sensible to store the
|
will in general read through down to the database. To avoid multiple reads, it is sensible to store the
|
||||||
result in a local variable in suitable scope (e.g. method, class or jsp).
|
result in a local variable in suitable scope (e.g. method, class or jsp).
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<preface id="reference:preface">
|
<preface id="reference:preface">
|
||||||
<title>Reference Documentation</title>
|
<title>Reference Documentation</title>
|
||||||
<section>
|
<section>
|
||||||
<title>Spring Data and Spring Data Graph</title>
|
<title>Spring Data and Spring Data Neo4j</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<ulink url="http://springsource.org/spring-data">Spring Data</ulink> is a SpringSource project that aims to
|
<ulink url="http://springsource.org/spring-data">Spring Data</ulink> is a SpringSource project that aims to
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The Spring Data Graph project, as part of the Spring Data initiative, aims to simplify development
|
The Spring Data Neo4j project, as part of the Spring Data initiative, aims to simplify development
|
||||||
with the Neo4j graph database. Like JPA, it uses annotations on simple POJO domain objects.
|
with the Neo4j graph database. Like JPA, it uses annotations on simple POJO domain objects.
|
||||||
The annotations activate the AspectJ aspects in the Spring Data Graph framework, mapping the POJO entities
|
The annotations activate the AspectJ aspects in the Spring Data Neo4j framework, mapping the POJO entities
|
||||||
and their fields to nodes, relationships, and properties in the graph database.
|
and their fields to nodes, relationships, and properties in the graph database.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph allows, at anytime, to drop down to the <xref linkend="neo4j" >Neo4j-API</xref> level to execute functionality with
|
Spring Data Neo4j allows, at anytime, to drop down to the <xref linkend="neo4j" >Neo4j-API</xref> level to execute functionality with
|
||||||
the highest performance possible.
|
the highest performance possible.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>Reference Documentation Overview</title>
|
<title>Reference Documentation Overview</title>
|
||||||
<para>
|
<para>
|
||||||
The explanation of Spring Data Graphs programming model starts with some underlying details.
|
The explanation of Spring Data Neo4js programming model starts with some underlying details.
|
||||||
The basic internal workings of Spring Data Graph are explained in the initial chapter about AspectJ <xref linkend="reference:aspectj"/>.
|
The basic internal workings of Spring Data Neo4j are explained in the initial chapter about AspectJ <xref linkend="reference:aspectj"/>.
|
||||||
It also explains some of the common issues around AspectJ tooling with the current IDEs.
|
It also explains some of the common issues around AspectJ tooling with the current IDEs.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Relationships between entities are first class citizens in a graph database and therefore worth a separate
|
Relationships between entities are first class citizens in a graph database and therefore worth a separate
|
||||||
<xref linkend="reference:programming_model:relationships" >chapter</xref> describing their usage in Spring Data Graph.
|
<xref linkend="reference:programming_model:relationships" >chapter</xref> describing their usage in Spring Data Neo4j.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
To add fields that are just backed by graph operations is a bit more involved. First you should know
|
To add fields that are just backed by graph operations is a bit more involved. First you should know
|
||||||
@@ -61,18 +61,18 @@
|
|||||||
<para>
|
<para>
|
||||||
You might probably use the additional
|
You might probably use the additional
|
||||||
entity methods (see <xref linkend="reference:programming-model:introduced-methods"/>) that are added to your
|
entity methods (see <xref linkend="reference:programming-model:introduced-methods"/>) that are added to your
|
||||||
domain objects by Spring Data Graph. Those allow you to manage the entity lifecycles as well as to connect entities.
|
domain objects by Spring Data Neo4j. Those allow you to manage the entity lifecycles as well as to connect entities.
|
||||||
Those methods also provide the means to execute the mentioned graph operations with your entity as a starting point.
|
Those methods also provide the means to execute the mentioned graph operations with your entity as a starting point.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Indexing operations are useful for finding individual nodes and relationships in a graph. They can be used to
|
Indexing operations are useful for finding individual nodes and relationships in a graph. They can be used to
|
||||||
start graph operations or to be processed in your application. Indexing in the plain Neo4j API is a bit more involved.
|
start graph operations or to be processed in your application. Indexing in the plain Neo4j API is a bit more involved.
|
||||||
Spring Data Graph maintains automatic indexes per entity class, with @Indexed annotations on relevant fields.
|
Spring Data Neo4j maintains automatic indexes per entity class, with @Indexed annotations on relevant fields.
|
||||||
(<xref linkend="reference:programming-model:indexing"/>)
|
(<xref linkend="reference:programming-model:indexing"/>)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you don't want to go the path of persistence aware domain objects (Active-Record) but rather use a DAO layer,
|
If you don't want to go the path of persistence aware domain objects (Active-Record) but rather use a DAO layer,
|
||||||
Spring Data Commons provides a repository abstraction that is also implemented in Spring Data Graph. Those repositories
|
Spring Data Commons provides a repository abstraction that is also implemented in Spring Data Neo4j. Those repositories
|
||||||
just consist of a composition of interfaces that declare the available methods on the concrete repository. The implementation
|
just consist of a composition of interfaces that declare the available methods on the concrete repository. The implementation
|
||||||
details are handled by the library. At least for typical CRUD, Index- and Query-operatoins that is very convenient.
|
details are handled by the library. At least for typical CRUD, Index- and Query-operatoins that is very convenient.
|
||||||
For custom implementations of repository methods you are free to add your own code. (<xref linkend="reference:programming-model:repositories"/>).
|
For custom implementations of repository methods you are free to add your own code. (<xref linkend="reference:programming-model:repositories"/>).
|
||||||
@@ -85,12 +85,12 @@
|
|||||||
The need of an active transaction for mutating the state of nodes or relationships implies that direct changes to
|
The need of an active transaction for mutating the state of nodes or relationships implies that direct changes to
|
||||||
the graph are only possible in a transactional context. Unfortunately many higher level application layers don't
|
the graph are only possible in a transactional context. Unfortunately many higher level application layers don't
|
||||||
want to care about transactions and the open-session-in-view pattern is not widely used. Therefore Spring Data
|
want to care about transactions and the open-session-in-view pattern is not widely used. Therefore Spring Data
|
||||||
Graph introduced an entity lifecyle and added support for detached entities which can be used for temporary
|
Neo4j introduced an entity lifecyle and added support for detached entities which can be used for temporary
|
||||||
domain objects that are not intended to be stored in the graph or which will be attached to the graph only later.
|
domain objects that are not intended to be stored in the graph or which will be attached to the graph only later.
|
||||||
(<xref linkend="reference:programming-model:lifecycle"/>)
|
(<xref linkend="reference:programming-model:lifecycle"/>)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Unlike Neo4j which is a schema free database, Spring Data Graph works on Java domain objects. So it needs to store
|
Unlike Neo4j which is a schema free database, Spring Data Neo4j works on Java domain objects. So it needs to store
|
||||||
the type information of the entities in the graph to be able to reconstruct them when just nodes are retrieved. To
|
the type information of the entities in the graph to be able to reconstruct them when just nodes are retrieved. To
|
||||||
achieve that it employs type-representation-strategies which are described in a separate chapter.
|
achieve that it employs type-representation-strategies which are described in a separate chapter.
|
||||||
(<xref linkend="reference:programming-model:typerepresentationstrategy"/>)
|
(<xref linkend="reference:programming-model:typerepresentationstrategy"/>)
|
||||||
@@ -101,29 +101,29 @@
|
|||||||
or hierarchies. How that works is explained here: <xref linkend="reference:programming-model:projection"/>.
|
or hierarchies. How that works is explained here: <xref linkend="reference:programming-model:projection"/>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph offers basic support for bean property validation (JSR-303). Annotations from that JSR are recognized
|
Spring Data Neo4j offers basic support for bean property validation (JSR-303). Annotations from that JSR are recognized
|
||||||
and evaluated whenever a property is set, or when a previously detached entity is persisted to the graph.
|
and evaluated whenever a property is set, or when a previously detached entity is persisted to the graph.
|
||||||
(see <xref linkend="reference:programming-model:validation"/>)
|
(see <xref linkend="reference:programming-model:validation"/>)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Unfortunately the setup of Spring Data Graph is more involved than we'd like. That is partly due to the maven setup
|
Unfortunately the setup of Spring Data Neo4j is more involved than we'd like. That is partly due to the maven setup
|
||||||
and dependencies, which can be alleviated by using different build systems like gradle or ant/ivy. The Spring configuration
|
and dependencies, which can be alleviated by using different build systems like gradle or ant/ivy. The Spring configuration
|
||||||
itself boils down to two lines of <code><datagraph></code> namespace setup. (see <xref linkend="setup"/>)
|
itself boils down to two lines of <code><spring-neo4j></code> namespace setup. (see <xref linkend="setup"/>)
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph can also be used in a JPA environment to add graph features to your JPA entities. In the <xref linkend="reference:cross-store"/>
|
Spring Data Neo4j can also be used in a JPA environment to add graph features to your JPA entities. In the <xref linkend="reference:cross-store"/>
|
||||||
the slightly different behavior and setup of a Graph-JPA interaction are described.
|
the slightly different behavior and setup of a Graph-JPA interaction are described.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The provided samples, which are also publicly hosted on <ulink url="http://github.com/springsource/spring-data-graph-examples">github</ulink> are explained in
|
The provided samples, which are also publicly hosted on <ulink url="http://github.com/springsource/spring-data-neo4j-examples">github</ulink> are explained in
|
||||||
<xref linkend="reference:samples"/>.
|
<xref linkend="reference:samples"/>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The performance implications of using Spring Data Graph are detailed in <xref linkend="reference:performance"/>. This chapter also discusses
|
The performance implications of using Spring Data Neo4j are detailed in <xref linkend="reference:performance"/>. This chapter also discusses
|
||||||
which usecases should be handled with Spring Data Graph and when it should not be used.
|
which usecases should be handled with Spring Data Neo4j and when it should not be used.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Being a Spring Data library, Spring Data Graph also implements a comprehensive template for interacting with the Neo4j graph database.
|
Being a Spring Data library, Spring Data Neo4j also implements a comprehensive template for interacting with the Neo4j graph database.
|
||||||
The <xref linkend="reference:template">Neo4jTemplate</xref> provides all basic graph operations as well as advanced querying with
|
The <xref linkend="reference:template">Neo4jTemplate</xref> provides all basic graph operations as well as advanced querying with
|
||||||
Indexes, Cypher, Gremlin and Traversals with a convenient API.
|
Indexes, Cypher, Gremlin and Traversals with a convenient API.
|
||||||
</para>
|
</para>
|
||||||
@@ -132,15 +132,15 @@
|
|||||||
are explained in <xref linkend="reference:aspectj-details"/>.
|
are explained in <xref linkend="reference:aspectj-details"/>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
How to consume the REST-API of a Neo4j-Server is the topic of <xref linkend="reference:neo4j-server"/>. But Spring Data Graph can also
|
How to consume the REST-API of a Neo4j-Server is the topic of <xref linkend="reference:neo4j-server"/>. But Spring Data Neo4j can also
|
||||||
be used to create custom Extensions for the Neo4j Server which would serve domain model abstractions to a suitable front-end. So instead of
|
be used to create custom Extensions for the Neo4j Server which would serve domain model abstractions to a suitable front-end. So instead of
|
||||||
talking low level primitives to a database, the front-end would communicate via a domain level protocol with endpoints implemented
|
talking low level primitives to a database, the front-end would communicate via a domain level protocol with endpoints implemented
|
||||||
in Jersey and Spring Data Graph.
|
in Jersey and Spring Data Neo4j.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
As Spring Data Graph is based on AspectJ and uses some advanced features of that toolset, please
|
As Spring Data Neo4j is based on AspectJ and uses some advanced features of that toolset, please
|
||||||
be aware of that. Please see the section on AspectJ (<xref linkend="reference:aspectj"/>) for
|
be aware of that. Please see the section on AspectJ (<xref linkend="reference:aspectj"/>) for
|
||||||
details if you run into any problems.
|
details if you run into any problems.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
<section id="reference:aspectj">
|
<section id="reference:aspectj">
|
||||||
<title>AspectJ support</title>
|
<title>AspectJ support</title>
|
||||||
<para>
|
<para>
|
||||||
Behind the scenes, Spring Data Graph leverages <ulink url="http://www.eclipse.org/aspectj/">AspectJ</ulink>
|
Behind the scenes, Spring Data Neo4j leverages <ulink url="http://www.eclipse.org/aspectj/">AspectJ</ulink>
|
||||||
aspects to modify the behavior of simple annotated POJO entities
|
aspects to modify the behavior of simple annotated POJO entities
|
||||||
(see <xref linkend="reference:aspectj-details"/>). Each node entity is backed by a graph node that holds its
|
(see <xref linkend="reference:aspectj-details"/>). Each node entity is backed by a graph node that holds its
|
||||||
properties and relationships to other entities. AspectJ is used for intercepting field access, so that
|
properties and relationships to other entities. AspectJ is used for intercepting field access, so that
|
||||||
Spring Data Graph can retrieve the information from the entity's backing node or relationship in the database.
|
Spring Data Neo4j can retrieve the information from the entity's backing node or relationship in the database.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The aspect introduces some internal fields and some public methods
|
The aspect introduces some internal fields and some public methods
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
Introduced methods for <code>equals()</code> and <code>hashCode()</code> use the underlying node or relationship.
|
Introduced methods for <code>equals()</code> and <code>hashCode()</code> use the underlying node or relationship.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph internally uses an abstraction called <code>EntityState</code> that the field
|
Spring Data Neo4j internally uses an abstraction called <code>EntityState</code> that the field
|
||||||
access and instantiation advices of the aspect delegate to. This way, the aspect code is kept to a
|
access and instantiation advices of the aspect delegate to. This way, the aspect code is kept to a
|
||||||
minimum, focusing mainly on the pointcuts and delegation code. The <code>EntityState</code> then uses
|
minimum, focusing mainly on the pointcuts and delegation code. The <code>EntityState</code> then uses
|
||||||
a number of <code>FieldAccessorFactories</code> to create a <code>FieldAccessor</code> instance per
|
a number of <code>FieldAccessorFactories</code> to create a <code>FieldAccessor</code> instance per
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<title>AspectJ IDE support</title>
|
<title>AspectJ IDE support</title>
|
||||||
<para>
|
<para>
|
||||||
As Spring Data Graph uses some advanced features of AspectJ, users may experience issues with
|
As Spring Data Neo4j uses some advanced features of AspectJ, users may experience issues with
|
||||||
their IDE reporting errors where in fact there are none. Features that might be reported wrongfully
|
their IDE reporting errors where in fact there are none. Features that might be reported wrongfully
|
||||||
include: introduction of methods to interfaces, declaration of additional interfaces for annotated
|
include: introduction of methods to interfaces, declaration of additional interfaces for annotated
|
||||||
classes, and generified introduced methods.
|
classes, and generified introduced methods.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ movie.setTopActor(actor);
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Neither the actor nor the movie has been assigned a node in the graph. If we were to call
|
Neither the actor nor the movie has been assigned a node in the graph. If we were to call
|
||||||
<code>movie.persist()</code>, then Spring Data Graph would first create a node for the movie.
|
<code>movie.persist()</code>, then Spring Data Neo4j would first create a node for the movie.
|
||||||
It would then note that there is a relationship to an actor, so it would call actor.persist()
|
It would then note that there is a relationship to an actor, so it would call actor.persist()
|
||||||
in a cascading fashion. Once the actor has been persisted, it will create the relationship
|
in a cascading fashion. Once the actor has been persisted, it will create the relationship
|
||||||
from the movie to the actor. All of this will be done atomically in one transaction.
|
from the movie to the actor. All of this will be done atomically in one transaction.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<section id="reference:programming-model:validation">
|
<section id="reference:programming-model:validation">
|
||||||
<title>Bean validation (JSR-303)</title>
|
<title>Bean validation (JSR-303)</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph supports property-based validation support. When a property is changed, it is
|
Spring Data Neo4j supports property-based validation support. When a property is changed, it is
|
||||||
checked against the annotated constraints, e.g. <code>@Min</code>, <code>@Max</code>,
|
checked against the annotated constraints, e.g. <code>@Min</code>, <code>@Max</code>,
|
||||||
<code>@Size</code>, etc. Validation errors throw a <code>ValidationException</code>. The validation
|
<code>@Size</code>, etc. Validation errors throw a <code>ValidationException</code>. The validation
|
||||||
support that comes with Spring is used for evaluating the constraints. To use this feature, a validator
|
support that comes with Spring is used for evaluating the constraints. To use this feature, a validator
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<title>Exact and numeric index</title>
|
<title>Exact and numeric index</title>
|
||||||
<para>
|
<para>
|
||||||
When using the standard Neo4j API, nodes and relationships have to be manually indexed with
|
When using the standard Neo4j API, nodes and relationships have to be manually indexed with
|
||||||
key-value pairs, typically being the property name and value. When using Spring Data Graph,
|
key-value pairs, typically being the property name and value. When using Spring Data Neo4j,
|
||||||
this task is simplified to just adding an <code>@Indexed</code> annotation on entity fields
|
this task is simplified to just adding an <code>@Indexed</code> annotation on entity fields
|
||||||
by which the entity should be searchable. This will result in automatic updates of the index
|
by which the entity should be searchable. This will result in automatic updates of the index
|
||||||
every time an indexed field changes.
|
every time an indexed field changes.
|
||||||
@@ -62,7 +62,7 @@ for (Person middleAgedDeveloper : graphRepository.findAllByRange("age", 20, 40))
|
|||||||
<section>
|
<section>
|
||||||
<title>Fulltext indexes</title>
|
<title>Fulltext indexes</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph also supports fulltext indexes. By default, indexed fields are stored in
|
Spring Data Neo4j also supports fulltext indexes. By default, indexed fields are stored in
|
||||||
an exact lookup index. To have them analyzed and prepared for fulltext search, the
|
an exact lookup index. To have them analyzed and prepared for fulltext search, the
|
||||||
<code>@Indexed</code> annotation has the boolean <code>fulltext</code> attribute.
|
<code>@Indexed</code> annotation has the boolean <code>fulltext</code> attribute.
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class Movie {
|
|||||||
<para>
|
<para>
|
||||||
It is not necessary to annotate data fields, as they are persisted by default; all fields that
|
It is not necessary to annotate data fields, as they are persisted by default; all fields that
|
||||||
contain primitive values are persisted directly to the graph. All fields convertible to String
|
contain primitive values are persisted directly to the graph. All fields convertible to String
|
||||||
using the Spring conversion services will be stored as a string. Spring Data Graph includes a
|
using the Spring conversion services will be stored as a string. Spring Data Neo4j includes a
|
||||||
custom conversion factory that comes with converters for <code>Enum</code>s and <code>Date</code>s.
|
custom conversion factory that comes with converters for <code>Enum</code>s and <code>Date</code>s.
|
||||||
Transient fields are not persisted.
|
Transient fields are not persisted.
|
||||||
</para>
|
</para>
|
||||||
@@ -75,7 +75,7 @@ public class Movie {
|
|||||||
<title>@Query: fields as query result views</title>
|
<title>@Query: fields as query result views</title>
|
||||||
<para>
|
<para>
|
||||||
The <code>@Query</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
|
Spring Data Neo4j 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 named <code>%start</code>
|
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>.
|
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
|
Graph queries can return variable number of entities. That's why annotation can be put onto fields
|
||||||
@@ -104,7 +104,7 @@ public class Group {
|
|||||||
<title>@GraphTraversal: fields as traversal result views</title>
|
<title>@GraphTraversal: fields as traversal result views</title>
|
||||||
<para>
|
<para>
|
||||||
The <code>@GraphTraversal</code> annotation leverages the delegation infrastructure used by the
|
The <code>@GraphTraversal</code> annotation leverages the delegation infrastructure used by the
|
||||||
Spring Data Graph aspects. It provides dynamic fields which, when accessed, return an Iterable
|
Spring Data Neo4j aspects. It provides dynamic fields which, when accessed, return an Iterable
|
||||||
of node entities that are the result of a traversal starting at the entity containing the field.
|
of node entities that are the result of a traversal starting at the entity containing the field.
|
||||||
The <code>TraversalDescription</code> used for this is created by the
|
The <code>TraversalDescription</code> used for this is created by the
|
||||||
<code>FieldTraversalDescriptionBuilder</code> class defined by the <code>traversalBuilder</code>
|
<code>FieldTraversalDescriptionBuilder</code> class defined by the <code>traversalBuilder</code>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<chapter id="programming-model" xmlns:xi="http://www.w3.org/2001/XInclude">
|
<chapter id="programming-model" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<title>Programming model</title>
|
<title>Programming model</title>
|
||||||
<para>
|
<para>
|
||||||
This chapter covers the fundamentals of the programming model behind Spring Data Graph. It discusses the
|
This chapter covers the fundamentals of the programming model behind Spring Data Neo4j. It discusses the
|
||||||
AspectJ features used and the annotations provided by Spring Data Graph and how to use them.
|
AspectJ features used and the annotations provided by Spring Data Neo4j and how to use them.
|
||||||
Examples for this section are taken from the "IMDB" project of
|
Examples for this section are taken from the "IMDB" project of
|
||||||
<ulink url="http://github.com/SpringSource/spring-data-graph-examples">Spring Data Graph examples</ulink>.
|
<ulink url="http://github.com/SpringSource/spring-data-neo4j-examples">Spring Data Neo4j examples</ulink>.
|
||||||
</para>
|
</para>
|
||||||
<xi:include href="aspectj.xml"/>
|
<xi:include href="aspectj.xml"/>
|
||||||
<xi:include href="node-entities.xml"/>
|
<xi:include href="node-entities.xml"/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
(not related in the inheritance hierarchy or even an interface) order type that is valid in the current
|
(not related in the inheritance hierarchy or even an interface) order type that is valid in the current
|
||||||
context and only offers the attributes and methods needed here would be very benefitial.
|
context and only offers the attributes and methods needed here would be very benefitial.
|
||||||
</para>
|
</para>
|
||||||
<para>Spring Data Graph offers initial support for projecting node and relationship entities to different target
|
<para>Spring Data Neo4j offers initial support for projecting node and relationship entities to different target
|
||||||
types. All instances of this projected entity share the same backing node or relationship, so data changes are
|
types. All instances of this projected entity share the same backing node or relationship, so data changes are
|
||||||
reflected immediately.
|
reflected immediately.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -6,19 +6,19 @@
|
|||||||
Since relationships are first-class citizens in Neo4j, associations between node entities are represented
|
Since relationships are first-class citizens in Neo4j, associations between node entities are represented
|
||||||
by relationships. In general, relationships are categorized by a type, and start and end nodes (which
|
by relationships. In general, relationships are categorized by a type, and start and end nodes (which
|
||||||
imply the direction of the relationship). Relationships can have an arbitrary number of properties.
|
imply the direction of the relationship). Relationships can have an arbitrary number of properties.
|
||||||
Spring Data Graph has special support to represent Neo4j relationships as entities too, but it is often
|
Spring Data Neo4j has special support to represent Neo4j relationships as entities too, but it is often
|
||||||
not needed.
|
not needed.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
As of Neo4j 1.4.M03, circular references are allowed. Spring Data Graph reflects this accordingly.
|
As of Neo4j 1.4.M03, circular references are allowed. Spring Data Neo4j reflects this accordingly.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<section id="reference:programming_model:relationships:relatedto">
|
<section id="reference:programming_model:relationships:relatedto">
|
||||||
<title>@RelatedTo: Connecting node entities</title>
|
<title>@RelatedTo: Connecting node entities</title>
|
||||||
<para>
|
<para>
|
||||||
Every field of a node entity that references one or more other node entities is backed by relationships
|
Every field of a node entity that references one or more other node entities is backed by relationships
|
||||||
in the graph. These relationships are managed by Spring Data Graph automatically.
|
in the graph. These relationships are managed by Spring Data Neo4j automatically.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The simplest kind of relationship is a single field pointing to another node entity (1:1).
|
The simplest kind of relationship is a single field pointing to another node entity (1:1).
|
||||||
@@ -56,15 +56,15 @@ public class Actor {
|
|||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Fields referencing other entities should not be manually initialized, as they are managed by
|
Fields referencing other entities should not be manually initialized, as they are managed by
|
||||||
Spring Data Graph under the hood. 1:N fields can be accessed immediately, and Spring Data Graph
|
Spring Data Neo4j under the hood. 1:N fields can be accessed immediately, and Spring Data Neo4j
|
||||||
will provide a java.util.Set representing the relationships. If the returned set is modified,
|
will provide a java.util.Set representing the relationships. If the returned set is modified,
|
||||||
the changes are reflected in the graph. Spring Data Graph also ensures that there is only one
|
the changes are reflected in the graph. Spring Data Neo4j also ensures that there is only one
|
||||||
relationship of a given type between any two given entities.
|
relationship of a given type between any two given entities.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
Before an entity has been attached with <code>persist()</code> for the first time, it will
|
Before an entity has been attached with <code>persist()</code> for the first time, it will
|
||||||
not have its state managed by Spring Data Graph. For example, given the Actor class defined above,
|
not have its state managed by Spring Data Neo4j. For example, given the Actor class defined above,
|
||||||
if <code>actor.movies</code> was accessed in a non-persisted entity, it would return
|
if <code>actor.movies</code> was accessed in a non-persisted entity, it would return
|
||||||
<code>null</code>, whereas if it was accessed in a persisted entity, it would return
|
<code>null</code>, whereas if it was accessed in a persisted entity, it would return
|
||||||
an empty managed set.
|
an empty managed set.
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
<section id="reference:programming-model:repositories">
|
<section id="reference:programming-model:repositories">
|
||||||
<title>CRUD with repositories</title>
|
<title>CRUD with repositories</title>
|
||||||
<para>
|
<para>
|
||||||
The repositories provided by Spring Data Graph build on the composable repository infrastructure
|
The repositories provided by Spring Data Neo4j build on the composable repository infrastructure
|
||||||
in <ulink url="http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/#repositories.custom-implementations">Spring Data Commons</ulink>.
|
in <ulink url="http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/#repositories.custom-implementations">Spring Data Commons</ulink>.
|
||||||
They allow for interface based composition of repositories consisting of provided default
|
They allow for interface based composition of repositories consisting of provided default
|
||||||
implementations for certain interfaces and additional custom implementations for other methods.
|
implementations for certain interfaces and additional custom implementations for other methods.
|
||||||
</para>
|
</para>
|
||||||
<!--<note>-->
|
<!--<note>-->
|
||||||
<!--<para>-->
|
<!--<para>-->
|
||||||
<!--Spring Data Graph provides only the infrastructure and some default repository implementations-->
|
<!--Spring Data Neo4j provides only the infrastructure and some default repository implementations-->
|
||||||
<!--so far. Future releases will support finders derived from method names, named queries, and-->
|
<!--so far. Future releases will support finders derived from method names, named queries, and-->
|
||||||
<!--annotated query methods.-->
|
<!--annotated query methods.-->
|
||||||
<!--(e.g.-->
|
<!--(e.g.-->
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
<!--</para>-->
|
<!--</para>-->
|
||||||
<!--</note>-->
|
<!--</note>-->
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph repositories support annotated and named queries for the Neo4j
|
Spring Data Neo4j repositories support annotated and named queries for the Neo4j
|
||||||
<ulink url="http://docs.neo4j.org/chunked/milestone/query-lang.html">Cypher</ulink> query-language.
|
<ulink url="http://docs.neo4j.org/chunked/milestone/query-lang.html">Cypher</ulink> query-language.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph comes with typed repository implementations that provide methods for
|
Spring Data Neo4j comes with typed repository implementations that provide methods for
|
||||||
locating node and relationship entities. There are 3 types of basic repository interfaces
|
locating node and relationship entities. There are 3 types of basic repository interfaces
|
||||||
and implementations. <code>CRUDRepository</code> provides basic operations,
|
and implementations. <code>CRUDRepository</code> provides basic operations,
|
||||||
<code>IndexRepository</code> and <code>NamedIndexRepository</code> delegate to Neo4j's internal
|
<code>IndexRepository</code> and <code>NamedIndexRepository</code> delegate to Neo4j's internal
|
||||||
@@ -147,8 +147,8 @@
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Named Queries</title>
|
<title>Named Queries</title>
|
||||||
<para>Spring Data Graph also supports the notion of named queries which are externalized in property-config-files
|
<para>Spring Data Neo4j 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>META-INF/neo4j-named-queries.properties</code>). Those files have the format:
|
||||||
<code>Entity.finderName=query</code> (e.g. <code>Person.findBoss=start p=(%person) match (p)<-[:BOSS]-(boss) return boss</code>).
|
<code>Entity.finderName=query</code> (e.g. <code>Person.findBoss=start p=(%person) match (p)<-[:BOSS]-(boss) return boss</code>).
|
||||||
Otherwise named queries support the same parameters as annotated queries. For using the named parameters you have to either
|
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.
|
annotate the parameters of the method with the <code>@Param("person")</code> annotation or enable debug symbols.
|
||||||
@@ -256,7 +256,7 @@ public class PersonRepositoryImpl implements PersonRepositoryExtension {
|
|||||||
|
|
||||||
// configure the repositories, preferably via the datagraph:repositories namespace
|
// configure the repositories, preferably via the datagraph:repositories namespace
|
||||||
// (graphDatabaseContext reference is optional)
|
// (graphDatabaseContext reference is optional)
|
||||||
<datagraph:repositories base-package="org.springframework.data.neo4j"
|
<neo4j:repositories base-package="org.springframework.data.neo4j"
|
||||||
graph-database-context-ref="graphDatabaseContext"/>
|
graph-database-context-ref="graphDatabaseContext"/>
|
||||||
|
|
||||||
// have it injected
|
// have it injected
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
boundaries. Reading data does however not require transactions.
|
boundaries. Reading data does however not require transactions.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph integrates with transaction managers configured using Spring. The simplest
|
Spring Data Neo4j integrates with transaction managers configured using Spring. The simplest
|
||||||
scenario of just running the graph database uses a SpringTransactionManager provided by the
|
scenario of just running the graph database uses a SpringTransactionManager provided by the
|
||||||
Neo4j kernel to be used with Spring's JtaTransactionManager. That is, configuring Spring to
|
Neo4j kernel to be used with Spring's JtaTransactionManager. That is, configuring Spring to
|
||||||
use Neo4j's transaction manager.
|
use Neo4j's transaction manager.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<para>
|
<para>
|
||||||
The explicit XML configuration given below is encoded in the <code>Neo4jConfiguration</code>
|
The explicit XML configuration given below is encoded in the <code>Neo4jConfiguration</code>
|
||||||
configuration bean that uses Spring's <code>@Configuration</code> feature. This greatly
|
configuration bean that uses Spring's <code>@Configuration</code> feature. This greatly
|
||||||
simplifies the configuration of Spring Data Graph.
|
simplifies the configuration of Spring Data Neo4j.
|
||||||
<!--An example is shown further below.-->
|
<!--An example is shown further below.-->
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
<para>
|
<para>
|
||||||
One can also configure a stock XA transaction manager (e.g. Atomikos, JOTM, App-Server-TM) to be
|
One can also configure a stock XA transaction manager (e.g. Atomikos, JOTM, App-Server-TM) to be
|
||||||
used with Neo4j and the other resources. For a bit less secure but fast 1 phase commit best effort,
|
used with Neo4j and the other resources. For a bit less secure but fast 1 phase commit best effort,
|
||||||
use <code>ChainedTransactionManager</code>, which comes bundled with Spring Data Graph. It takes a
|
use <code>ChainedTransactionManager</code>, which comes bundled with Spring Data Neo4j. It takes a
|
||||||
list of transaction managers as constructor params and will handle them in order for transaction
|
list of transaction managers as constructor params and will handle them in order for transaction
|
||||||
start and commit (or rollback) in the reverse order.
|
start and commit (or rollback) in the reverse order.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph will by default autodetect which are the most suitable strategies for node and relationship
|
Spring Data Neo4j will by default autodetect which are the most suitable strategies for node and relationship
|
||||||
entities. For new data stores, it will always opt for the indexing strategies. If a data store was created
|
entities. For new data stores, it will always opt for the indexing strategies. If a data store was created
|
||||||
with the older<code>SubReferenceNodeTypeRepresentationStrategy</code>, then it will continue to use that
|
with the older<code>SubReferenceNodeTypeRepresentationStrategy</code>, then it will continue to use that
|
||||||
strategy for node entities. It will however in that case use the no-op strategy for relationship entities,
|
strategy for node entities. It will however in that case use the no-op strategy for relationship entities,
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
<section id="samples:introduction">
|
<section id="samples:introduction">
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph comes with a number of sample applications. The source code of the samples can be found on
|
Spring Data Neo4j comes with a number of sample applications. The source code of the samples can be found on
|
||||||
<ulink url="http://github.com/SpringSource/spring-data-graph-examples">Github</ulink>. The different sample
|
<ulink url="http://github.com/SpringSource/spring-data-neo4j-examples">Github</ulink>. The different sample
|
||||||
projects are introduced below.
|
projects are introduced below.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
and then prints them.
|
and then prints them.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The unit tests demonstrate some other features of Spring Data Graph as well. The sample comes
|
The unit tests demonstrate some other features of Spring Data Neo4j as well. The sample comes
|
||||||
with a minimal configuration for Maven and Spring to get up and running quickly.
|
with a minimal configuration for Maven and Spring to get up and running quickly.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
into the graph database. It allows the listing of movies with their actors, and of actors and their
|
into the graph database. It allows the listing of movies with their actors, and of actors and their
|
||||||
roles in different movies. It also uses graph traversal operations to calculate the
|
roles in different movies. It also uses graph traversal operations to calculate the
|
||||||
<ulink url="http://en.wikipedia.org/wiki/Bacon_number">Bacon number</ulink> of any given actor.
|
<ulink url="http://en.wikipedia.org/wiki/Bacon_number">Bacon number</ulink> of any given actor.
|
||||||
This sample application shows the usage of Spring Data Graph in a more complex setting, using several
|
This sample application shows the usage of Spring Data Neo4j in a more complex setting, using several
|
||||||
annotated entities and relationships as well as indexes and graph traversals.
|
annotated entities and relationships as well as indexes and graph traversals.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
Simple, JPA-based web application for managing users and restaurants, with the ability to add
|
Simple, JPA-based web application for managing users and restaurants, with the ability to add
|
||||||
restaurants as favorites to a user. It is basically the foundation for the MyRestaurants-Social
|
restaurants as favorites to a user. It is basically the foundation for the MyRestaurants-Social
|
||||||
application (see<xref linkend="samples:myrestaurants-social" />), and does therefore not use
|
application (see<xref linkend="samples:myrestaurants-social" />), and does therefore not use
|
||||||
Spring Data Graph.
|
Spring Data Neo4j.
|
||||||
</para>
|
</para>
|
||||||
<mediaobject>
|
<mediaobject>
|
||||||
<imageobject>
|
<imageobject>
|
||||||
|
|||||||
@@ -3,20 +3,20 @@
|
|||||||
<chapter id="setup">
|
<chapter id="setup">
|
||||||
<title>Environment setup</title>
|
<title>Environment setup</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph dramatically simplifies development, but some setup is naturally required.
|
Spring Data Neo4j dramatically simplifies development, but some setup is naturally required.
|
||||||
For building the application, Maven needs to be configured to include the Spring Data Graph dependencies,
|
For building the application, Maven needs to be configured to include the Spring Data Neo4j dependencies,
|
||||||
and configure the AspectJ weaving. After the build setup is complete, the Spring application needs to be
|
and configure the AspectJ weaving. After the build setup is complete, the Spring application needs to be
|
||||||
configured to make use of Spring Data Graph.
|
configured to make use of Spring Data Neo4j.
|
||||||
<!--Examples for this setup can be found in the -->
|
<!--Examples for this setup can be found in the -->
|
||||||
<!--<ulink url="http://github.com/SpringSource/spring-data-graph-examples">Spring Data Graph examples</ulink>.-->
|
<!--<ulink url="http://github.com/SpringSource/spring-data-neo4j-examples">Spring Data Neo4j examples</ulink>.-->
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph projects can be built using maven, we also added means to build them with gradle and ant/ivy.
|
Spring Data Neo4j projects can be built using maven, we also added means to build them with gradle and ant/ivy.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section>
|
||||||
<title>Gradle configuration</title>
|
<title>Gradle configuration</title>
|
||||||
<para>
|
<para>
|
||||||
The necessary build plugin to build Spring Data Graph projects with gradle is available as part of the
|
The necessary build plugin to build Spring Data Neo4j projects with gradle is available as part of the
|
||||||
SDG distribution or on github which makes the usage as easy as:
|
SDG distribution or on github which makes the usage as easy as:
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
targetCompatibility = 1.6
|
targetCompatibility = 1.6
|
||||||
|
|
||||||
springVersion = "3.0.5.RELEASE"
|
springVersion = "3.0.5.RELEASE"
|
||||||
springDataGraphVersion = "1.1.0"
|
springDataNeo4jVersion = "1.1.0"
|
||||||
aspectjVersion = "1.6.12.M1
|
aspectjVersion = "1.6.12.M1
|
||||||
|
|
||||||
apply from:'https://github.com/SpringSource/spring-data-graph/raw/master/build/
|
apply from:'https://github.com/SpringSource/spring-data-neo4j/raw/master/build/
|
||||||
gradle/springdatagraph.gradle'
|
gradle/springdataneo4j.gradle'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
runtime
|
runtime
|
||||||
@@ -42,15 +42,15 @@ repositories {
|
|||||||
}]]></programlisting>
|
}]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
The actual springdatagraph.gradle is very simple just decorating the javac tasks with the iajc ant task.
|
The actual springdataneo4j.gradle is very simple just decorating the javac tasks with the iajc ant task.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<title>Ant/Ivy configuration</title>
|
<title>Ant/Ivy configuration</title>
|
||||||
<para>
|
<para>
|
||||||
The supplied sample ant <ulink
|
The supplied sample ant <ulink
|
||||||
url="https://github.com/SpringSource/spring-data-graph/raw/master/build/ivy">build configuration</ulink> is mainly about resolving
|
url="https://github.com/SpringSource/spring-data-neo4j/raw/master/build/ivy">build configuration</ulink> is mainly about resolving
|
||||||
the dependencies for Spring Data Graph and AspectJ using Ivy and integrating the iajc ant task in the build.
|
the dependencies for Spring Data Neo4j and AspectJ using Ivy and integrating the iajc ant task in the build.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Ant/Ivy Build Configuration</title>
|
<title>Ant/Ivy Build Configuration</title>
|
||||||
@@ -73,14 +73,14 @@ repositories {
|
|||||||
<section>
|
<section>
|
||||||
<title>Maven configuration</title>
|
<title>Maven configuration</title>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph projects are easiest to build with Apache Maven. The main dependencies are: Spring
|
Spring Data Neo4j projects are easiest to build with Apache Maven. The main dependencies are: Spring
|
||||||
Data Graph itself, Spring Data Commons, parts of the Spring Framework, and the Neo4j graph database.
|
Data Neo4j itself, Spring Data Commons, parts of the Spring Framework, and the Neo4j graph database.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Repositories</title>
|
<title>Repositories</title>
|
||||||
<para>
|
<para>
|
||||||
The milestone releases of Spring Data Graph are available from the dedicated milestone
|
The milestone releases of Spring Data Neo4j are available from the dedicated milestone
|
||||||
repository. Neo4j releases and milestones are available from Maven Central.
|
repository. Neo4j releases and milestones are available from Maven Central.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -122,7 +122,7 @@ repositories {
|
|||||||
<section>
|
<section>
|
||||||
<title>AspectJ build configuration</title>
|
<title>AspectJ build configuration</title>
|
||||||
<para>
|
<para>
|
||||||
Since Spring Data Graph uses AspectJ for build-time aspect weaving of entities, it is necessary to
|
Since Spring Data Neo4j uses AspectJ for build-time aspect weaving of entities, it is necessary to
|
||||||
hook in the AspectJ Maven plugin to the build process. The plugin also has its own dependencies. You
|
hook in the AspectJ Maven plugin to the build process. The plugin also has its own dependencies. You
|
||||||
also need to explicitly specify the aspect libraries (spring-aspects and spring-data-neo4j).
|
also need to explicitly specify the aspect libraries (spring-aspects and spring-data-neo4j).
|
||||||
</para>
|
</para>
|
||||||
@@ -177,14 +177,14 @@ repositories {
|
|||||||
<section>
|
<section>
|
||||||
<title>Spring configuration</title>
|
<title>Spring configuration</title>
|
||||||
<para>
|
<para>
|
||||||
Users of Spring Data Graph have two ways of very concisely configuring it. Either they can use a
|
Users of Spring Data Neo4j have two ways of very concisely configuring it. Either they can use a
|
||||||
Spring Data Graph XML configuration namespace, or they can use a Java-based bean configuration.
|
Spring Data Neo4j XML configuration namespace, or they can use a Java-based bean configuration.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section>
|
||||||
<title>XML namespace</title>
|
<title>XML namespace</title>
|
||||||
<para>
|
<para>
|
||||||
The XML namespace can be used to configure Spring Data Graph. The <code>config</code> element
|
The XML namespace can be used to configure Spring Data Neo4j. The <code>config</code> element
|
||||||
provides an XML-based configuration of Spring Data Graph in one line. It has three attributes.
|
provides an XML-based configuration of Spring Data Neo4j in one line. It has three attributes.
|
||||||
<code>graphDatabaseService</code> points out the Neo4j instance to use. For convenience,
|
<code>graphDatabaseService</code> points out the Neo4j instance to use. For convenience,
|
||||||
<code>storeDirectory</code> can be set instead of <code>graphDatabaseService</code> to
|
<code>storeDirectory</code> can be set instead of <code>graphDatabaseService</code> to
|
||||||
point to a directory where a new <code>EmbeddedGraphDatabase</code> will be created. For
|
point to a directory where a new <code>EmbeddedGraphDatabase</code> will be created. For
|
||||||
@@ -197,17 +197,17 @@ repositories {
|
|||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:datagraph="http://www.springframework.org/schema/data/graph"
|
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context
|
||||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||||
http://www.springframework.org/schema/data/graph
|
http://www.springframework.org/schema/data/neo4j
|
||||||
http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd">
|
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||||
|
|
||||||
<context:annotation-config/>
|
<context:annotation-config/>
|
||||||
<datagraph:config storeDirectory="target/config-test"/>
|
<neo4j:config storeDirectory="target/config-test"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
@@ -221,7 +221,7 @@ repositories {
|
|||||||
<constructor-arg index="0" value="target/config-test" />
|
<constructor-arg index="0" value="target/config-test" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<datagraph:config graphDatabaseService="graphDatabaseService"/>
|
<neo4j:config graphDatabaseService="graphDatabaseService"/>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
<example>
|
<example>
|
||||||
@@ -234,7 +234,7 @@ repositories {
|
|||||||
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
|
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<datagraph:config storeDirectory="target/config-test"
|
<neo4j:config storeDirectory="target/config-test"
|
||||||
entityManagerFactory="entityManagerFactory"/>
|
entityManagerFactory="entityManagerFactory"/>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -242,7 +242,7 @@ repositories {
|
|||||||
<section>
|
<section>
|
||||||
<title>Java-based bean configuration</title>
|
<title>Java-based bean configuration</title>
|
||||||
<para>
|
<para>
|
||||||
You can also configure Spring Data Graph using Java-based bean metadata.
|
You can also configure Spring Data Neo4j using Java-based bean metadata.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
@@ -255,7 +255,7 @@ repositories {
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
In order to configure Spring Data Graph with Java-based bean metadata, the class
|
In order to configure Spring Data Neo4j with Java-based bean metadata, the class
|
||||||
<code>Neo4jConfiguration</code> is registered with the context. This is either done
|
<code>Neo4jConfiguration</code> is registered with the context. This is either done
|
||||||
explicitly in the context configuration, or via classpath scanning for classes that
|
explicitly in the context configuration, or via classpath scanning for classes that
|
||||||
have the @Configuration annotation. The only thing that must be provided is the
|
have the @Configuration annotation. The only thing that must be provided is the
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
<title>Annotating the domain</title>
|
<title>Annotating the domain</title>
|
||||||
<subtitle>Decorations</subtitle>
|
<subtitle>Decorations</subtitle>
|
||||||
<para>
|
<para>
|
||||||
Looking at the Spring Data Graph documentation, we found a simple
|
Looking at the Spring Data Neo4j documentation, we found a simple
|
||||||
<ulink url="http://github.com/SpringSource/spring-data-graph-examples/tree/master/hello-worlds">Hello World example</ulink>
|
<ulink url="http://github.com/SpringSource/spring-data-neo4j-examples/tree/master/hello-worlds">Hello World example</ulink>
|
||||||
and tried to understand it. The entity classes were annotated with <code>@NodeEntity</code>.
|
and tried to understand it. The entity classes were annotated with <code>@NodeEntity</code>.
|
||||||
That was simple, so we added the annotation to our domain classes too. Entity classes representing
|
That was simple, so we added the annotation to our domain classes too. Entity classes representing
|
||||||
relationships were instead annotated with <code>@RelationshipEntity</code>.
|
relationships were instead annotated with <code>@RelationshipEntity</code>.
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class Actor {
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
While reading about these relationship collections, we learned that they are actually
|
While reading about these relationship collections, we learned that they are actually
|
||||||
Spring Data Graph-managed sets. So whenever we add or remove something from the set,
|
Spring Data Neo4j-managed sets. So whenever we add or remove something from the set,
|
||||||
it automatically gets reflected in the underlying relationships. That's neat! But this
|
it automatically gets reflected in the underlying relationships. That's neat! But this
|
||||||
also meant we did not need to initialize the fields. That could be easy to forget.
|
also meant we did not need to initialize the fields. That could be easy to forget.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface MovieRepository extends GraphRepository<Movie> {}
|
|||||||
Then we added it to the Spring context configuration by simply adding:
|
Then we added it to the Spring context configuration by simply adding:
|
||||||
<example>
|
<example>
|
||||||
<title>Repository context configuration</title>
|
<title>Repository context configuration</title>
|
||||||
<programlisting language="xml"><![CDATA[<datagraph:repositories base-package="org.neo4j.cineasts.repository"/>
|
<programlisting language="xml"><![CDATA[<neo4j:repositories base-package="org.neo4j.cineasts.repository"/>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
We then created the domain-specific repository class, annotating it with <code>@Repository</code> and
|
We then created the domain-specific repository class, annotating it with <code>@Repository</code> and
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
the convenience of the Spring programming model to NOSQL databases. That should be in line with
|
the convenience of the Spring programming model to NOSQL databases. That should be in line with
|
||||||
what we already know, providing us with a quick start. We had a look at the list of projects
|
what we already know, providing us with a quick start. We had a look at the list of projects
|
||||||
supporting the different NOSQL databases out there. Only one of them mentioned the kind of social
|
supporting the different NOSQL databases out there. Only one of them mentioned the kind of social
|
||||||
network we were thinking of - Spring Data Graph for Neo4j, a graph database. Neo4j's slogan of
|
network we were thinking of - Spring Data Neo4j for the Neo4j graph database. Neo4j's slogan of
|
||||||
"value in relationships" and the accompanying docs looked like what we needed.
|
"value in relationships" and the accompanying docs looked like what we needed.
|
||||||
We decided to give it a try.
|
We decided to give it a try.
|
||||||
</para>
|
</para>
|
||||||
@@ -90,8 +90,8 @@
|
|||||||
showing a static view. See the Spring Framework documentation for information on doing this.
|
showing a static view. See the Spring Framework documentation for information on doing this.
|
||||||
</para>
|
</para>
|
||||||
<!--<para>-->
|
<!--<para>-->
|
||||||
<!--Next was the setting up of Spring Data Graph. We looked at the README at the Spring Data Graph-->
|
<!--Next was the setting up of Spring Data Neo4j. We looked at the README at the Spring Data Neo4j-->
|
||||||
<!--Github, and then checked the Spring Data Graph manual. There was a bit of Maven setup for AspectJ-->
|
<!--Github, and then checked the Spring Data Neo4j manual. There was a bit of Maven setup for AspectJ-->
|
||||||
<!--but apart from that, not much new stuff. Time to add a few lines to our Spring configuration.-->
|
<!--but apart from that, not much new stuff. Time to add a few lines to our Spring configuration.-->
|
||||||
<!--</para>-->
|
<!--</para>-->
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<title>Users</title>
|
<title>Users</title>
|
||||||
<para>
|
<para>
|
||||||
So we started out by taking the User class that we'd already coded and made it a
|
So we started out by taking the User class that we'd already coded and made it a
|
||||||
full-fledged Spring Data Graph entity. We added the ability to make friends and to
|
full-fledged Spring Data Neo4j entity. We added the ability to make friends and to
|
||||||
rate movies. With that we also added a simple UserRepository that was able to look
|
rate movies. With that we also added a simple UserRepository that was able to look
|
||||||
up users by ID.
|
up users by ID.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.docbook.org/xml/4.4/docbookx.dtd">
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.docbook.org/xml/4.4/docbookx.dtd">
|
||||||
<chapter id="tutorial_about-spring-data">
|
<chapter id="tutorial_about-spring-data">
|
||||||
<title>Spring Data Graph</title>
|
<title>Spring Data Neo4j</title>
|
||||||
<subtitle>Conjuring magic</subtitle>
|
<subtitle>Conjuring magic</subtitle>
|
||||||
<para>
|
<para>
|
||||||
So far it had all been pure Spring Framework and Neo4j. However, using the Neo4j code in our domain
|
So far it had all been pure Spring Framework and Neo4j. However, using the Neo4j code in our domain
|
||||||
classes polluted them with graph database details. For this application, we wanted to keep the domain
|
classes polluted them with graph database details. For this application, we wanted to keep the domain
|
||||||
classes clean. Spring Data Graph promised to do the heavy lifting for us, so we continued investigating it.
|
classes clean. Spring Data Neo4j promised to do the heavy lifting for us, so we continued investigating it.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Spring Data Graph depends heavily on AspectJ <xref linkend="reference:aspectj-details">features</xref>.
|
Spring Data Neo4j depends heavily on AspectJ <xref linkend="reference:aspectj-details">features</xref>.
|
||||||
Some parts of our classes would get new behavior,
|
Some parts of our classes would get new behavior,
|
||||||
but it would not be visible in our code. The upside of this is that you get rid of a lot of boilerplate
|
but it would not be visible in our code. The upside of this is that you get rid of a lot of boilerplate
|
||||||
code.
|
code.
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<para>
|
<para>
|
||||||
The first step was to configure Maven:
|
The first step was to configure Maven:
|
||||||
<example>
|
<example>
|
||||||
<title>Spring Data Graph Maven configuration</title>
|
<title>Spring Data Neo4j Maven configuration</title>
|
||||||
<programlisting language="xml"><![CDATA[<properties>
|
<programlisting language="xml"><![CDATA[<properties>
|
||||||
<aspectj.version>1.6.12.M1</aspectj.version>
|
<aspectj.version>1.6.12.M1</aspectj.version>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -82,13 +82,13 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<example>
|
<example>
|
||||||
<title>Spring Data Graph context configuration</title>
|
<title>Spring Data Neo4j context configuration</title>
|
||||||
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans" ...
|
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans" ...
|
||||||
xmlns:datagraph="http://www.springframework.org/schema/data/graph"
|
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||||
xsi:schemaLocation="... http://www.springframework.org/schema/data/graph
|
xsi:schemaLocation="... http://www.springframework.org/schema/data/neo4j
|
||||||
http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd">
|
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||||
...
|
...
|
||||||
<datagraph:config storeDirectory="data/graph.db"/>
|
<neo4j:config storeDirectory="data/graph.db"/>
|
||||||
...
|
...
|
||||||
</beans>
|
</beans>
|
||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
were impressive. This sections presents some of the remaining screen shots of Cineasts.net.
|
were impressive. This sections presents some of the remaining screen shots of Cineasts.net.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Some noteworthy things. Since Spring Data Graph reads through down to the database for property
|
Some noteworthy things. Since Spring Data Neo4j reads through down to the database for property
|
||||||
and relationship access, we tried to minimize that by using <code><c:var/></code> several times.
|
and relationship access, we tried to minimize that by using <code><c:var/></code> several times.
|
||||||
The app contains very little javascript / ajax code right now, that will change when it moves ahead.
|
The app contains very little javascript / ajax code right now, that will change when it moves ahead.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
Reference in New Issue
Block a user