diff --git a/spring-data-neo4j-examples/cineasts-aspects/pom.xml b/spring-data-neo4j-examples/cineasts-aspects/pom.xml
index 921fd99ac..ec13e2c24 100644
--- a/spring-data-neo4j-examples/cineasts-aspects/pom.xml
+++ b/spring-data-neo4j-examples/cineasts-aspects/pom.xml
@@ -13,7 +13,7 @@
UTF-8
3.0.7.RELEASE
1.6.1
- 1.6
+ 1.7-SNAPSHOT
${project.version}
1.6.12
1.6.1
diff --git a/spring-data-neo4j-examples/cineasts-rest/pom.xml b/spring-data-neo4j-examples/cineasts-rest/pom.xml
index da10b03ac..4ee9d7db7 100644
--- a/spring-data-neo4j-examples/cineasts-rest/pom.xml
+++ b/spring-data-neo4j-examples/cineasts-rest/pom.xml
@@ -13,7 +13,7 @@
UTF-8
3.0.7.RELEASE
1.6.1
- 1.6
+ 1.7-SNAPSHOT
${project.version}
1.6.12
1.6.1
@@ -340,10 +340,10 @@
org.apache.felix
org.apache.felix.fileinstall
-
+
org.slf4j
slf4j-jdk14
diff --git a/spring-data-neo4j-examples/cineasts-rest/src/test/resources/movies-test-context.xml b/spring-data-neo4j-examples/cineasts-rest/src/test/resources/movies-test-context.xml
index 5bf2d9dd5..79e779057 100644
--- a/spring-data-neo4j-examples/cineasts-rest/src/test/resources/movies-test-context.xml
+++ b/spring-data-neo4j-examples/cineasts-rest/src/test/resources/movies-test-context.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/spring-data-neo4j-examples/cineasts/pom.xml b/spring-data-neo4j-examples/cineasts/pom.xml
index 5898b8738..9cf2d0479 100644
--- a/spring-data-neo4j-examples/cineasts/pom.xml
+++ b/spring-data-neo4j-examples/cineasts/pom.xml
@@ -16,7 +16,7 @@
${project.version}
1.6.1
1.6.12
- 1.6
+ 1.7-SNAPSHOT
diff --git a/spring-data-neo4j-examples/myrestaurants-social/pom.xml b/spring-data-neo4j-examples/myrestaurants-social/pom.xml
index c96f8e1cd..cab2dd614 100644
--- a/spring-data-neo4j-examples/myrestaurants-social/pom.xml
+++ b/spring-data-neo4j-examples/myrestaurants-social/pom.xml
@@ -11,7 +11,7 @@
${project.version}
1.6.12
1.6.1
- 1.6
+ 1.7-SNAPSHOT
UTF-8
3.0.7.RELEASE
diff --git a/spring-data-neo4j-examples/todos/pom.xml b/spring-data-neo4j-examples/todos/pom.xml
index 6ae6c3965..10a467a41 100644
--- a/spring-data-neo4j-examples/todos/pom.xml
+++ b/spring-data-neo4j-examples/todos/pom.xml
@@ -11,7 +11,7 @@
UTF-8
- 1.6
+ 1.7-SNAPSHOT
3.0.7.RELEASE
${project.version}
1.6.12
@@ -193,7 +193,6 @@
org.springframework
spring-web
${spring.version}
-
commons-logging
@@ -205,7 +204,6 @@
org.springframework
spring-webmvc
${spring.version}
-
commons-logging
diff --git a/spring-data-neo4j-parent/pom.xml b/spring-data-neo4j-parent/pom.xml
index 9adfadd3b..dbd7b1f7f 100644
--- a/spring-data-neo4j-parent/pom.xml
+++ b/spring-data-neo4j-parent/pom.xml
@@ -126,7 +126,7 @@
3.0.7.RELEASE
4.0.0.RELEASE
[${org.springframework.version.30}, ${org.springframework.version.40})
- 1.2.1.RELEASE
+ 1.3.0.RC1
1.7-SNAPSHOT
0.8-SNAPSHOT
1.6.12
@@ -345,7 +345,7 @@
com.tinkerpop.gremlin
gremlin-groovy
${gremlin.version}
- jar
+ true
org.neo4j
@@ -404,13 +404,6 @@
true
-
- com.tinkerpop.gremlin
- gremlin-groovy
- ${gremlin.version}
- true
-
-
javax.annotation
jsr250-api
@@ -467,7 +460,7 @@
org.neo4j
neo4j-cypher-dsl
- 1.6.M02
+ ${neo4j.version}
@@ -771,14 +764,23 @@
tinkerpop-repository
http://tinkerpop.com/maven2
+
+ false
+
jboss-repository
http://repository.jboss.org/nexus/content/groups/public-jboss
+
+ false
+
neo4j-public-release-repository
http://m2.neo4j.org/releases
+
+ false
+
neo4j-public-snapshot-repository
diff --git a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestBase.java b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestBase.java
index 3f95f7e2f..38a622fd2 100644
--- a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestBase.java
+++ b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestBase.java
@@ -33,7 +33,7 @@ public class RestTestBase {
protected SpringRestGraphDatabase restGraphDatabase;
private static final String HOSTNAME = "127.0.0.1";
- public static final int PORT = 7473;
+ public static final int PORT = 7470;
protected static LocalTestServer neoServer = new LocalTestServer(HOSTNAME,PORT).withPropertiesFile("test-db.properties");
public static final String SERVER_ROOT_URI = "http://" + HOSTNAME + ":" + PORT + "/db/data/";
diff --git a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestHelper.java b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestHelper.java
index 6a1b9064b..b6830e060 100644
--- a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestHelper.java
+++ b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/RestTestHelper.java
@@ -28,7 +28,7 @@ public class RestTestHelper
protected SpringRestGraphDatabase graphDb;
private static final String HOSTNAME = "localhost";
- private static final int PORT = 7473;
+ private static final int PORT = 7470;
private static LocalTestServer neoServer;
private static final String SERVER_ROOT_URI = "http://" + HOSTNAME + ":" + PORT + "/db/data/";
diff --git a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/SpringPluginInitializerTest.java b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/SpringPluginInitializerTest.java
index 4aef88f46..f427bcf85 100644
--- a/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/SpringPluginInitializerTest.java
+++ b/spring-data-neo4j-rest/src/test/java/org/springframework/data/neo4j/rest/support/SpringPluginInitializerTest.java
@@ -42,7 +42,7 @@ public class SpringPluginInitializerTest extends SpringPluginInitializer impleme
private static int touched = 0;
private static final String HOSTNAME = "localhost";
- private static final int PORT = 7473;
+ private static final int PORT = 7470;
@Path( "/testInterface" )
@POST
@@ -87,7 +87,7 @@ public class SpringPluginInitializerTest extends SpringPluginInitializer impleme
private RequestResult sendRequest( String method ) {
return RequestResult.extractFrom(Client.create().
- resource( "http://localhost:7473/test/" + method ).
+ resource( "http://"+HOSTNAME+":"+PORT+"/test/" + method ).
type( MediaType.APPLICATION_JSON ).
accept( MediaType.APPLICATION_JSON ).post( ClientResponse.class ));
}
diff --git a/spring-data-neo4j-rest/src/test/resources/RestTest-context.xml b/spring-data-neo4j-rest/src/test/resources/RestTest-context.xml
index fc588c66b..25eff83ed 100644
--- a/spring-data-neo4j-rest/src/test/resources/RestTest-context.xml
+++ b/spring-data-neo4j-rest/src/test/resources/RestTest-context.xml
@@ -15,6 +15,6 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
+
diff --git a/spring-data-neo4j/pom.xml b/spring-data-neo4j/pom.xml
index 759835b36..8d8c131ab 100644
--- a/spring-data-neo4j/pom.xml
+++ b/spring-data-neo4j/pom.xml
@@ -128,7 +128,6 @@
org.neo4j
neo4j-cypher-dsl
-
org.neo4j
diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java
index ab90c3e7b..7a677224b 100644
--- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java
+++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java
@@ -46,6 +46,7 @@ import org.springframework.data.neo4j.support.index.IndexProviderImpl;
import org.springframework.data.neo4j.support.mapping.ClassNameAlias;
import org.springframework.data.neo4j.support.mapping.EntityAlias;
import org.springframework.data.neo4j.support.mapping.EntityStateHandler;
+import org.springframework.data.neo4j.support.mapping.IndexCreationMappingEventListener;
import org.springframework.data.neo4j.support.mapping.Neo4jEntityFetchHandler;
import org.springframework.data.neo4j.support.mapping.Neo4jMappingContext;
import org.springframework.data.neo4j.support.mapping.SourceStateTransmitter;
@@ -241,6 +242,11 @@ public abstract class Neo4jConfiguration {
return createJtaTransactionManager();
}
+ @Bean
+ public IndexCreationMappingEventListener indexCreationMappingEventListener() throws Exception {
+ return new IndexCreationMappingEventListener(neo4jTemplate());
+ }
+
protected JtaTransactionManager createJtaTransactionManager() {
JtaTransactionManager jtaTm = new JtaTransactionManager();
final GraphDatabaseService gds = getGraphDatabaseService();
diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/AbstractGraphRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/AbstractGraphRepository.java
index dafbd8623..56c95038f 100644
--- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/AbstractGraphRepository.java
+++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/AbstractGraphRepository.java
@@ -104,17 +104,17 @@ public abstract class AbstractGraphRepository im
}
@Override
- public T save(T entity) {
- return (T) template.save(entity);
+ public U save(U entity) {
+ return template.save(entity);
}
@SuppressWarnings("unchecked")
@Override
- public Iterable save(Iterable extends T> entities) {
- for (T entity : entities) {
+ public Iterable save(Iterable entities) {
+ for (U entity : entities) {
save(entity);
}
- return (Iterable) entities;
+ return (Iterable) entities;
}
/**
@@ -358,6 +358,33 @@ public abstract class AbstractGraphRepository im
return page;
}
+ @Override
+ public Iterable findAll(final Iterable ids) {
+ return new Iterable() {
+ @Override
+ public Iterator iterator() {
+ final Iterator idIterator = ids.iterator();
+ return new Iterator() {
+
+ @Override
+ public boolean hasNext() {
+ return idIterator.hasNext();
+ }
+
+ @Override
+ public T next() {
+ return template.findOne(idIterator.next(), clazz);
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ };
+ }
+
private PageImpl extractPage(Pageable pageable, int count, int offset, Iterator iterator) {
final List result = new ArrayList(count);
int total=subList(offset, count, iterator, result);
diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/CRUDRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/CRUDRepository.java
index 262c093df..507761185 100644
--- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/CRUDRepository.java
+++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/CRUDRepository.java
@@ -38,7 +38,7 @@ public interface CRUDRepository extends PagingAndSortingRepository {
* @return the saved entity (being the same reference as the parameter)
*/
@Transactional
- T save(T entity);
+ U save(U entity);
/**
@@ -47,7 +47,7 @@ public interface CRUDRepository extends PagingAndSortingRepository {
* @return the input iterable
*/
@Transactional
- Iterable save(Iterable extends T> entities);
+ Iterable save(Iterable entities);
/**
diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/IndexCreationMappingEventListener.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/IndexCreationMappingEventListener.java
new file mode 100644
index 000000000..87789fcaa
--- /dev/null
+++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/IndexCreationMappingEventListener.java
@@ -0,0 +1,53 @@
+/**
+ * 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.support.mapping;
+
+import org.springframework.context.ApplicationListener;
+import org.springframework.data.mapping.PropertyHandler;
+import org.springframework.data.mapping.event.MappingContextEvent;
+import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity;
+import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
+import org.springframework.data.neo4j.support.Neo4jTemplate;
+import org.springframework.data.neo4j.support.index.IndexType;
+
+/**
+ * @author mh
+ * @since 12.04.12
+ */
+public class IndexCreationMappingEventListener implements ApplicationListener, Neo4jPersistentProperty>> {
+ private Neo4jTemplate template;
+
+ public IndexCreationMappingEventListener(Neo4jTemplate template) {
+ this.template = template;
+ }
+
+ @Override
+ public void onApplicationEvent(MappingContextEvent, Neo4jPersistentProperty> event) {
+ if (!(event.getSource() instanceof Neo4jPersistentEntity)) return;
+
+ final Neo4jPersistentEntity entity = event.getPersistentEntity();
+ final Class entityType = entity.getType();
+ template.getIndex(entityType, null, IndexType.SIMPLE);
+ entity.doWithProperties(new PropertyHandler() {
+ @Override
+ public void doWithPersistentProperty(Neo4jPersistentProperty property) {
+ if (property.isIndexed()) {
+ template.getIndex(property, entityType);
+ }
+ }
+ });
+ }
+}
diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/node/Neo4jHelper.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/node/Neo4jHelper.java
index 32a68bad6..3f972f906 100644
--- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/node/Neo4jHelper.java
+++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/node/Neo4jHelper.java
@@ -18,14 +18,43 @@ package org.springframework.data.neo4j.support.node;
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.index.IndexManager;
+import org.neo4j.tooling.GlobalGraphOperations;
import org.springframework.data.neo4j.support.Neo4jTemplate;
+import java.util.HashMap;
+import java.util.Map;
+
public abstract class Neo4jHelper {
public static void cleanDb(Neo4jTemplate template) {
cleanDb(template.getGraphDatabaseService());
}
+ public static void dumpDb(GraphDatabaseService gds) {
+ final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(gds);
+ for (Node node : globalGraphOperations.getAllNodes()) {
+ System.out.println(dump(node));
+ }
+ for (Node node : globalGraphOperations.getAllNodes()) {
+ for (Relationship rel : node.getRelationships(Direction.OUTGOING)) {
+ System.out.println(node +"-[:"+rel.getType().name() +" "+dump(rel)+"]->"+rel.getEndNode());
+ }
+ }
+ }
+
+ private static String dump(PropertyContainer pc) {
+ final long id = pc instanceof Node ? ((Node) pc).getId() : ((Relationship) pc).getId();
+ try {
+ Map props = new HashMap();
+ for (String prop : pc.getPropertyKeys()) {
+ props.put(prop, pc.getProperty(prop));
+ }
+ return String.format("(%d) %s ", id, props);
+ } catch (Exception e) {
+ return "(" + id + ") " + e.getMessage();
+ }
+ }
+
public static void cleanDb(GraphDatabaseService graphDatabaseService) {
Transaction tx = graphDatabaseService.beginTx();
@@ -39,13 +68,14 @@ public abstract class Neo4jHelper {
}
private static void removeNodes(GraphDatabaseService graphDatabaseService) {
+ final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(graphDatabaseService);
Node refNode = graphDatabaseService.getReferenceNode();
- for (Node node : graphDatabaseService.getAllNodes()) {
+ for (Node node : globalGraphOperations.getAllNodes()) {
for (Relationship rel : node.getRelationships(Direction.OUTGOING)) {
rel.delete();
}
}
- for (Node node : graphDatabaseService.getAllNodes()) {
+ for (Node node : globalGraphOperations.getAllNodes()) {
if (!refNode.equals(node)) {
node.delete();
}
diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/NoIndexDerivedFinderTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/NoIndexDerivedFinderTest.java
new file mode 100644
index 000000000..17e997ce1
--- /dev/null
+++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/NoIndexDerivedFinderTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.repository;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.neo4j.helpers.collection.IteratorUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.neo4j.model.Person;
+import org.springframework.test.context.CleanContextCacheTestExecutionListener;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
+import org.springframework.transaction.annotation.Transactional;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:org/springframework/data/neo4j/repository/GraphRepositoryTest-context.xml")
+@TestExecutionListeners({CleanContextCacheTestExecutionListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
+public class NoIndexDerivedFinderTest {
+
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @Test @Transactional
+ public void findByAge() {
+ Iterable result = personRepository.findByAge(0);
+ assertEquals(0,IteratorUtil.count(result));
+ }
+
+ @Test @Transactional
+ public void findByName() {
+ Iterable result = personRepository.findByName("");
+ assertEquals(0,IteratorUtil.count(result));
+ }
+
+}
diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/PersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/PersonRepository.java
index a57357baf..72b4d1b08 100644
--- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/PersonRepository.java
+++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/PersonRepository.java
@@ -77,5 +77,7 @@ public interface PersonRepository extends GraphRepository, NamedIndexRep
Iterable findByName(String name);
Iterable findByPersonality(String personality);
+
+ Iterable findByAge(int age);
}
diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/FullNeo4jTemplateTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/FullNeo4jTemplateTest.java
index 8002f9c8d..e772d2c0c 100644
--- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/FullNeo4jTemplateTest.java
+++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/FullNeo4jTemplateTest.java
@@ -74,9 +74,9 @@ public class FullNeo4jTemplateTest {
@Before
public void setUp() throws Exception {
Neo4jHelper.cleanDb(neo4jTemplate);
- // graphDatabase = neo4jTemplate.getGraphDatabase();
referenceNode = graphDatabase.getReferenceNode();
createData();
+ Neo4jHelper.dumpDb(neo4jTemplate.getGraphDatabaseService());
}
private void createData() {
@@ -285,17 +285,17 @@ public class FullNeo4jTemplateTest {
@Test
public void shouldFindNextNodeViaCypher() throws Exception {
- assertSingleResult(node1, neo4jTemplate.query("start n=node(0) match n-->m return m", null).to(Node.class));
+ assertSingleResult(node1, neo4jTemplate.query("start n=node(0) match n-[:knows]->m return m", null).to(Node.class));
}
@Test
public void shouldFindNextNodeViaGremlin() throws Exception {
- assertSingleResult(node1, neo4jTemplate.execute("g.v(0).out", null).to(Node.class));
+ assertSingleResult(node1, neo4jTemplate.execute("g.v(0).outE.filter{it.label=='knows'}.inV", null).to(Node.class));
}
@Test
public void shouldGetDirectRelationship() throws Exception {
- assertSingleResult("rel1", neo4jTemplate.convert(referenceNode.getRelationships()).to(String.class, new RelationshipNameConverter()));
+ assertSingleResult("rel1", neo4jTemplate.convert(referenceNode.getRelationships(DynamicRelationshipType.withName("knows"))).to(String.class, new RelationshipNameConverter()));
}
@Test