diff --git a/README.md b/README.md index bb064d8ef..f2d5f48df 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ For more detailed questions, use the [forum](http://forum.springsource.org/forum public class WorldRepository { @Autowired - private FinderFactory finderFactory; + private FinderFactory graphRepositoryFactory; @Transactional public Collection makeSomeWorlds() { @@ -117,31 +117,31 @@ For more detailed questions, use the [forum](http://forum.springsource.org/forum return new World(name,moons).persist(); } - private NodeFinder finder() { - return finderFactory.createNodeEntityFinder(World.class); + private NodeFinder graphRepository() { + return graphRepositoryFactory.createNodeEntityFinder(World.class); } public World findWorldIdentifiedBy( long id ) { - return finder().findById( id ); + return graphRepository().findById( id ); } public Iterable findAllWorlds() { - return finder().findAll(); + return graphRepository().findAll(); } public long countWorlds() { - return finder().count(); + return graphRepository().count(); } public World findWorldNamed( String name ) { - return finder().findByPropertyValue( null, "name", name ); + return graphRepository().findByPropertyValue( null, "name", name ); } public World findWorldWithMoons( long moonCount ) { - return finder().findByPropertyValue( "moons", "moons", moonCount ); + return graphRepository().findByPropertyValue( "moons", "moons", moonCount ); } public Iterable findWorldsWithMoons( int moonCount ) { - return finder().findAllByPropertyValue( "moons", "moons", moonCount ); + return graphRepository().findAllByPropertyValue( "moons", "moons", moonCount ); } } diff --git a/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4JQuery.java b/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4JQuery.java index 68af99545..5051f58d7 100644 --- a/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4JQuery.java +++ b/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4JQuery.java @@ -17,9 +17,9 @@ package org.springframework.data.graph.neo4j.jpa; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.Finder; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.GraphRepository; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.Tuple2; import javax.persistence.*; @@ -39,7 +39,7 @@ import static org.springframework.util.ObjectUtils.nullSafeEquals; public class Neo4JQuery implements TypedQuery { protected final Class resultClass; protected final String qlString; - private final FinderFactory finderFactory; + private final DirectGraphRepositoryFactory graphRepositoryFactory; private final PersistenceUnitInfo info; private final Pattern fromPattern = Pattern.compile("^.*\\bfrom\\s+([A-Z][A-Za-z0-9]+)\\b.*"); private int startPosition = 0; @@ -47,38 +47,38 @@ public class Neo4JQuery implements TypedQuery { private QueryExecutor queryExecutor; private Map, Tuple2> parameters = new HashMap, Tuple2>(); - public Neo4JQuery(final String qlString, final FinderFactory finderFactory, final PersistenceUnitInfo info, Class resultClass) { + public Neo4JQuery(final String qlString, final DirectGraphRepositoryFactory graphRepositoryFactory, final PersistenceUnitInfo info, Class resultClass) { this.qlString = qlString; - this.finderFactory = finderFactory; + this.graphRepositoryFactory = graphRepositoryFactory; this.info = info; this.resultClass = resultClass; queryExecutor = createExecutor(qlString); } private QueryExecutor createExecutor(final String qlString) { - final Finder finder = getFinderFromQuery(qlString); + final GraphRepository graphRepository = getFinderFromQuery(qlString); if (qlString.contains(" count(")) { return new QueryExecutor() { @Override protected T findObject() { - return (T)Long.valueOf(finder.count()); + return (T)Long.valueOf(graphRepository.count()); } }; } return new QueryExecutor() { @Override protected Iterable findList() { - return (Iterable) finder.findAll(); + return (Iterable) graphRepository.findAll(); } }; } - private NodeFinder getFinderFromQuery(String qlString) { + private NodeGraphRepository getFinderFromQuery(String qlString) { final Matcher matcher = fromPattern.matcher(qlString); if (!matcher.matches()) throw new IllegalAccessError("Unable to parse query " + qlString); final String shortName = matcher.group(1); final Class entityClass = getEntityClass(shortName); - return finderFactory.createNodeEntityFinder(entityClass); + return graphRepositoryFactory.createNodeEntityRepository(entityClass); } abstract static class QueryExecutor { diff --git a/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManager.java b/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManager.java index 3b3471d35..72d7967ff 100644 --- a/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManager.java +++ b/spring-data-neo4j-roo/src/main/java/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManager.java @@ -19,7 +19,7 @@ package org.springframework.data.graph.neo4j.jpa; import org.neo4j.graphdb.*; import org.springframework.beans.factory.annotation.Configurable; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import org.springframework.transaction.annotation.Transactional; @@ -46,7 +46,7 @@ public class Neo4jEntityManager implements EntityManager { private Map params; private volatile boolean closed; - private final FinderFactory finderFactory; + private final DirectGraphRepositoryFactory graphRepositoryFactory; @Resource private EntityManagerFactory entityManagerFactory; @@ -55,11 +55,11 @@ public class Neo4jEntityManager implements EntityManager { this.graphDatabaseContext = graphDatabaseContext; this.info = info; this.params = params; - finderFactory = new FinderFactory(graphDatabaseContext); + graphRepositoryFactory = new DirectGraphRepositoryFactory(graphDatabaseContext); } public Neo4jEntityManager() { - finderFactory = new FinderFactory(graphDatabaseContext); + graphRepositoryFactory = new DirectGraphRepositoryFactory(graphDatabaseContext); } private Node nodeFor(final Object entity) { @@ -230,7 +230,7 @@ public class Neo4jEntityManager implements EntityManager { } public TypedQuery createNeo4jQuery(final String qlString, final Class entityClass) { - return new Neo4JQuery(qlString, finderFactory,info,entityClass); + return new Neo4JQuery(qlString, graphRepositoryFactory,info,entityClass); } /* diff --git a/spring-data-neo4j-roo/src/test/resources/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManagerTest-context.xml b/spring-data-neo4j-roo/src/test/resources/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManagerTest-context.xml index f37b31c94..8bff3b059 100644 --- a/spring-data-neo4j-roo/src/test/resources/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManagerTest-context.xml +++ b/spring-data-neo4j-roo/src/test/resources/org/springframework/data/graph/neo4j/jpa/Neo4jEntityManagerTest-context.xml @@ -112,19 +112,19 @@ - + - + - + - + diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/config/Neo4jConfiguration.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/config/Neo4jConfiguration.java index bba485461..09637ecf8 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/config/Neo4jConfiguration.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/config/Neo4jConfiguration.java @@ -30,7 +30,7 @@ import org.springframework.data.graph.neo4j.fieldaccess.Neo4jConversionServiceFa import org.springframework.data.graph.neo4j.fieldaccess.NodeDelegatingFieldAccessorFactory; import org.springframework.data.graph.neo4j.fieldaccess.NodeEntityStateFactory; import org.springframework.data.graph.neo4j.fieldaccess.RelationshipEntityStateFactory; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import org.springframework.data.graph.neo4j.support.NodeTypeStrategyFactoryBean; import org.springframework.data.graph.neo4j.support.node.Neo4jConstructorGraphEntityInstantiator; @@ -122,31 +122,31 @@ public class Neo4jConfiguration { } @Bean - public FinderFactory finderFactory(GraphDatabaseContext graphDatabaseContext) throws Exception { - return new FinderFactory(graphDatabaseContext); + public DirectGraphRepositoryFactory finderFactory(GraphDatabaseContext graphDatabaseContext) throws Exception { + return new DirectGraphRepositoryFactory(graphDatabaseContext); } @Bean - public Neo4jRelationshipBacking neo4jRelationshipBacking(GraphDatabaseContext graphDatabaseContext, FinderFactory finderFactory) { + public Neo4jRelationshipBacking neo4jRelationshipBacking(GraphDatabaseContext graphDatabaseContext, DirectGraphRepositoryFactory graphRepositoryFactory) { Neo4jRelationshipBacking aspect = Neo4jRelationshipBacking.aspectOf(); aspect.setGraphDatabaseContext(graphDatabaseContext); RelationshipEntityStateFactory entityStateFactory = new RelationshipEntityStateFactory(); entityStateFactory.setGraphDatabaseContext(graphDatabaseContext); - entityStateFactory.setFinderFactory(finderFactory); + entityStateFactory.setGraphRepositoryFactory(graphRepositoryFactory); aspect.setRelationshipEntityStateFactory(entityStateFactory); return aspect; } @Bean - public Neo4jNodeBacking neo4jNodeBacking(GraphDatabaseContext graphDatabaseContext, FinderFactory finderFactory) { + public Neo4jNodeBacking neo4jNodeBacking(GraphDatabaseContext graphDatabaseContext, DirectGraphRepositoryFactory graphRepositoryFactory) { Neo4jNodeBacking aspect = Neo4jNodeBacking.aspectOf(); aspect.setGraphDatabaseContext(graphDatabaseContext); NodeEntityStateFactory entityStateFactory = new NodeEntityStateFactory(); entityStateFactory.setGraphDatabaseContext(graphDatabaseContext); - entityStateFactory.setFinderFactory(finderFactory); + entityStateFactory.setGraphRepositoryFactory(graphRepositoryFactory); entityStateFactory.setEntityManagerFactory(entityManagerFactory); entityStateFactory.setNodeDelegatingFieldAccessorFactory( - new NodeDelegatingFieldAccessorFactory(graphDatabaseContext, finderFactory)); + new NodeDelegatingFieldAccessorFactory(graphDatabaseContext, graphRepositoryFactory)); aspect.setNodeEntityStateFactory(entityStateFactory); return aspect; } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/DelegatingFieldAccessorFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/DelegatingFieldAccessorFactory.java index ab4849d30..97f62615a 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/DelegatingFieldAccessorFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/DelegatingFieldAccessorFactory.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.data.graph.annotation.NodeEntity; import org.springframework.data.graph.annotation.RelationshipEntity; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import org.springframework.util.ReflectionUtils; @@ -34,15 +34,15 @@ public abstract class DelegatingFieldAccessorFactory implements FieldAccessor protected final GraphDatabaseContext graphDatabaseContext; - protected final FinderFactory finderFactory; + protected final DirectGraphRepositoryFactory graphRepositoryFactory; protected abstract Collection> createListenerFactories(); protected abstract Collection> createAccessorFactories(); - public DelegatingFieldAccessorFactory(final GraphDatabaseContext graphDatabaseContext, final FinderFactory finderFactory) { + public DelegatingFieldAccessorFactory(final GraphDatabaseContext graphDatabaseContext, final DirectGraphRepositoryFactory graphRepositoryFactory) { this.graphDatabaseContext = graphDatabaseContext; - this.finderFactory = finderFactory; + this.graphRepositoryFactory = graphRepositoryFactory; this.fieldAccessorFactories.addAll(createAccessorFactories()); this.fieldAccessorListenerFactories.addAll(createListenerFactories()); } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeDelegatingFieldAccessorFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeDelegatingFieldAccessorFactory.java index 0f894a243..2374873cf 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeDelegatingFieldAccessorFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeDelegatingFieldAccessorFactory.java @@ -17,7 +17,7 @@ package org.springframework.data.graph.neo4j.fieldaccess; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import java.util.Arrays; @@ -29,8 +29,8 @@ import java.util.Collection; */ public class NodeDelegatingFieldAccessorFactory extends DelegatingFieldAccessorFactory { - public NodeDelegatingFieldAccessorFactory(GraphDatabaseContext graphDatabaseContext, FinderFactory finderFactory) { - super(graphDatabaseContext, finderFactory); + public NodeDelegatingFieldAccessorFactory(GraphDatabaseContext graphDatabaseContext, DirectGraphRepositoryFactory graphRepositoryFactory) { + super(graphDatabaseContext, graphRepositoryFactory); } @Override @@ -54,7 +54,7 @@ public class NodeDelegatingFieldAccessorFactory extends DelegatingFieldAccessorF new SingleRelationshipFieldAccessorFactory(graphDatabaseContext), new OneToNRelationshipFieldAccessorFactory(graphDatabaseContext), new ReadOnlyOneToNRelationshipFieldAccessorFactory(graphDatabaseContext), - new TraversalFieldAccessorFactory(finderFactory), + new TraversalFieldAccessorFactory(graphRepositoryFactory), new OneToNRelationshipEntityFieldAccessorFactory(graphDatabaseContext) ); } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeEntityStateFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeEntityStateFactory.java index b9d574693..9abd4bd5f 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeEntityStateFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/NodeEntityStateFactory.java @@ -19,7 +19,7 @@ package org.springframework.data.graph.neo4j.fieldaccess; import org.neo4j.graphdb.Node; import org.springframework.data.graph.annotation.NodeEntity; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import javax.persistence.EntityManagerFactory; @@ -29,7 +29,7 @@ public class NodeEntityStateFactory { private GraphDatabaseContext graphDatabaseContext; - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; private EntityManagerFactory entityManagerFactory; @@ -38,7 +38,7 @@ public class NodeEntityStateFactory { public EntityState getEntityState(final NodeBacked entity) { final NodeEntity graphEntityAnnotation = entity.getClass().getAnnotation(NodeEntity.class); // todo cache ?? if (graphEntityAnnotation.partial()) { - final PartialNodeEntityState partialNodeEntityState = new PartialNodeEntityState(null, entity, entity.getClass(), graphDatabaseContext, finderFactory, getPersistenceUnitUtils()); + final PartialNodeEntityState partialNodeEntityState = new PartialNodeEntityState(null, entity, entity.getClass(), graphDatabaseContext, graphRepositoryFactory,getPersistenceUnitUtils()); return new DetachedEntityState(partialNodeEntityState, graphDatabaseContext) { @Override protected boolean isDetached() { @@ -66,8 +66,8 @@ public class NodeEntityStateFactory { this.graphDatabaseContext = graphDatabaseContext; } - public void setFinderFactory(FinderFactory finderFactory) { - this.finderFactory = finderFactory; + public void setGraphRepositoryFactory(DirectGraphRepositoryFactory graphRepositoryFactory) { + this.graphRepositoryFactory = graphRepositoryFactory; } public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) { diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/PartialNodeEntityState.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/PartialNodeEntityState.java index 3a7c30d6a..96a8734d4 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/PartialNodeEntityState.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/PartialNodeEntityState.java @@ -24,7 +24,7 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.data.graph.annotation.GraphProperty; import org.springframework.data.graph.annotation.RelatedTo; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import org.springframework.data.persistence.StateProvider; @@ -45,8 +45,8 @@ public class PartialNodeEntityState extends DefaultEn private final GraphDatabaseContext graphDatabaseContext; private PersistenceUnitUtil persistenceUnitUtil; - public PartialNodeEntityState(final Node underlyingState, final ENTITY entity, final Class type, final GraphDatabaseContext graphDatabaseContext, final FinderFactory finderFactory, PersistenceUnitUtil persistenceUnitUtil) { - super(underlyingState, entity, type, new DelegatingFieldAccessorFactory(graphDatabaseContext, finderFactory) { + public PartialNodeEntityState(final Node underlyingState, final ENTITY entity, final Class type, final GraphDatabaseContext graphDatabaseContext, final DirectGraphRepositoryFactory graphRepositoryFactory, PersistenceUnitUtil persistenceUnitUtil) { + super(underlyingState, entity, type, new DelegatingFieldAccessorFactory(graphDatabaseContext, graphRepositoryFactory) { @Override protected Collection> createListenerFactories() { @@ -78,7 +78,7 @@ public class PartialNodeEntityState extends DefaultEn }, new OneToNRelationshipFieldAccessorFactory(getGraphDatabaseContext()), new ReadOnlyOneToNRelationshipFieldAccessorFactory(getGraphDatabaseContext()), - new TraversalFieldAccessorFactory(finderFactory), + new TraversalFieldAccessorFactory(this.graphRepositoryFactory), new OneToNRelationshipEntityFieldAccessorFactory(getGraphDatabaseContext()) ); } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityState.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityState.java index e6d670559..e7fb1b599 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityState.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityState.java @@ -20,7 +20,7 @@ import org.neo4j.graphdb.NotInTransactionException; import org.neo4j.graphdb.Relationship; import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.data.graph.core.RelationshipBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; import java.util.Arrays; @@ -34,10 +34,10 @@ public class RelationshipEntityState extends private final GraphDatabaseContext graphDatabaseContext; - private final FinderFactory finderFactory; + private final DirectGraphRepositoryFactory graphRepositoryFactory; - public RelationshipEntityState(final Relationship underlyingState, final ENTITY entity, final Class type, final GraphDatabaseContext graphDatabaseContext, final FinderFactory finderFactory) { - super(underlyingState, entity, type, new DelegatingFieldAccessorFactory(graphDatabaseContext, finderFactory) { + public RelationshipEntityState(final Relationship underlyingState, final ENTITY entity, final Class type, final GraphDatabaseContext graphDatabaseContext, final DirectGraphRepositoryFactory graphRepositoryFactory) { + super(underlyingState, entity, type, new DelegatingFieldAccessorFactory(graphDatabaseContext, graphRepositoryFactory) { @Override protected Collection> createListenerFactories() { return Arrays.>asList( @@ -59,7 +59,7 @@ public class RelationshipEntityState extends } }); this.graphDatabaseContext = graphDatabaseContext; - this.finderFactory = finderFactory; + this.graphRepositoryFactory = graphRepositoryFactory; } @Override diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityStateFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityStateFactory.java index b91961f98..f21a837ac 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityStateFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/RelationshipEntityStateFactory.java @@ -18,25 +18,25 @@ package org.springframework.data.graph.neo4j.fieldaccess; import org.neo4j.graphdb.Relationship; import org.springframework.data.graph.core.RelationshipBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; public class RelationshipEntityStateFactory { private GraphDatabaseContext graphDatabaseContext; - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; public EntityState getEntityState(final RelationshipBacked entity) { - return new RelationshipEntityState(null,entity,entity.getClass(), graphDatabaseContext, finderFactory); + return new RelationshipEntityState(null,entity,entity.getClass(), graphDatabaseContext, graphRepositoryFactory); } public void setGraphDatabaseContext(GraphDatabaseContext graphDatabaseContext) { this.graphDatabaseContext = graphDatabaseContext; } - public void setFinderFactory(FinderFactory finderFactory) { - this.finderFactory = finderFactory; + public void setGraphRepositoryFactory(DirectGraphRepositoryFactory graphRepositoryFactory) { + this.graphRepositoryFactory = graphRepositoryFactory; } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/TraversalFieldAccessorFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/TraversalFieldAccessorFactory.java index 6b4c9ea98..cdf277d59 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/TraversalFieldAccessorFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/fieldaccess/TraversalFieldAccessorFactory.java @@ -21,8 +21,8 @@ import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.graph.annotation.GraphTraversal; import org.springframework.data.graph.core.FieldTraversalDescriptionBuilder; import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -31,12 +31,12 @@ import static org.springframework.data.graph.neo4j.fieldaccess.DoReturn.doReturn public class TraversalFieldAccessorFactory implements FieldAccessorFactory { - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; - public TraversalFieldAccessorFactory(FinderFactory finderFactory) { + public TraversalFieldAccessorFactory(DirectGraphRepositoryFactory graphRepositoryFactory) { super(); - this.finderFactory = finderFactory; + this.graphRepositoryFactory = graphRepositoryFactory; } @@ -51,7 +51,7 @@ public class TraversalFieldAccessorFactory implements FieldAccessorFactory forField(final Field field) { - return new TraversalFieldAccessor(field, finderFactory); + return new TraversalFieldAccessor(field, graphRepositoryFactory); } /** @@ -60,14 +60,14 @@ public class TraversalFieldAccessorFactory implements FieldAccessorFactory { protected final Field field; - private final FinderFactory finderFactory; + private final DirectGraphRepositoryFactory graphRepositoryFactory; private final FieldTraversalDescriptionBuilder fieldTraversalDescriptionBuilder; private Class target; protected String[] params; - public TraversalFieldAccessor(final Field field, FinderFactory finderFactory) { + public TraversalFieldAccessor(final Field field, DirectGraphRepositoryFactory graphRepositoryFactory) { this.field = field; - this.finderFactory = finderFactory; + this.graphRepositoryFactory = graphRepositoryFactory; final GraphTraversal graphEntityTraversal = field.getAnnotation(GraphTraversal.class); this.target = graphEntityTraversal.elementClass(); this.params = graphEntityTraversal.params(); @@ -86,7 +86,7 @@ public class TraversalFieldAccessorFactory implements FieldAccessorFactory finder = finderFactory.createNodeEntityFinder(target); + final NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(target); final TraversalDescription traversalDescription = fieldTraversalDescriptionBuilder.build(nodeBacked,field,params); return doReturn(finder.findAllByTraversal(nodeBacked, traversalDescription)); } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/AbstractFinder.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/AbstractGraphRepository.java similarity index 78% rename from spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/AbstractFinder.java rename to spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/AbstractGraphRepository.java index e7377dad3..ef2d6b246 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/AbstractFinder.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/AbstractGraphRepository.java @@ -1,4 +1,4 @@ -package org.springframework.data.graph.neo4j.finder; +package org.springframework.data.graph.neo4j.repository; import org.apache.lucene.search.NumericRangeQuery; import org.neo4j.graphdb.NotFoundException; @@ -6,10 +6,16 @@ import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.index.Index; import org.neo4j.graphdb.index.IndexHits; import org.neo4j.helpers.collection.IterableWrapper; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.data.graph.core.GraphBacked; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; /** * Repository like finder for Node and Relationship-Entities. Provides finder methods for direct access, access via {@link org.springframework.data.graph.core.TypeRepresentationStrategy} @@ -18,14 +24,15 @@ import java.util.Collections; * @param GraphBacked target of this finder, enables the finder methods to return this concrete type * @param Type of backing state, either Node or Relationship */ -public abstract class AbstractFinder> implements Finder { +@org.springframework.stereotype.Repository +public abstract class AbstractGraphRepository> implements GraphRepository, CRUDGraphRepository { /** * Target graphbacked type */ protected final Class clazz; protected final GraphDatabaseContext graphDatabaseContext; - public AbstractFinder(final GraphDatabaseContext graphDatabaseContext, final Class clazz) { + public AbstractGraphRepository(final GraphDatabaseContext graphDatabaseContext, final Class clazz) { this.graphDatabaseContext = graphDatabaseContext; this.clazz = clazz; } @@ -34,7 +41,7 @@ public abstract class AbstractFinder entities) { + for (T entity : entities) { + entity.remove(); + } + } + + @Override + public void deleteAll() { + delete(findAll()); + } + + @Override + public Iterable findAll(Sort sort) { + return findAll(); // todo + } + + @Override + public Page findAll(final Pageable pageable) { + int count = pageable.getOffset()+pageable.getPageSize(); + Iterable all = findAll(pageable.getSort()); + List result=new ArrayList(count); + for (T t : all) { + if (count == 0) break; + result.add(t); + count--; + } + return new PageImpl(result,pageable,result.size()); + } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/CRUDGraphRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/CRUDGraphRepository.java new file mode 100644 index 000000000..558df5596 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/CRUDGraphRepository.java @@ -0,0 +1,57 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.graph.core.GraphBacked; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.transaction.annotation.Transactional; + +import java.io.Serializable; +import java.util.List; + +/** + * @author mh + * @since 28.03.11 + */ +public interface CRUDGraphRepository> extends PagingAndSortingRepository { + + @Transactional + T save(T entity); + + + @Transactional + Iterable save(Iterable entities); + + + T findOne(Long id); + + + boolean exists(Long id); + + + Iterable findAll(); + + + Long count(); + + + @Transactional + void delete(T entity); + + + @Transactional + void delete(Iterable entities); + + + @Transactional + void deleteAll(); + + + Iterable findAll(Sort sort); + + + Page findAll(Pageable pageable); + +} \ No newline at end of file diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/NodeFinder.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultNodeGraphRepository.java similarity index 67% rename from spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/NodeFinder.java rename to spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultNodeGraphRepository.java index ab6f45930..55ea13f46 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/NodeFinder.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultNodeGraphRepository.java @@ -14,17 +14,16 @@ * limitations under the License. */ -package org.springframework.data.graph.neo4j.finder; +package org.springframework.data.graph.neo4j.repository; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.traversal.TraversalDescription; -import org.springframework.data.graph.core.GraphBacked; import org.springframework.data.graph.core.NodeBacked; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; -public class NodeFinder> extends AbstractFinder { +public class DefaultNodeGraphRepository extends AbstractGraphRepository implements NodeGraphRepository { - public NodeFinder(final Class clazz, final GraphDatabaseContext graphDatabaseContext) { + public DefaultNodeGraphRepository(final Class clazz, final GraphDatabaseContext graphDatabaseContext) { super(graphDatabaseContext, clazz); } @@ -37,5 +36,18 @@ public class NodeFinder> extends AbstractFinder Iterable findAllByTraversal(final N startNode, final TraversalDescription traversalDescription) { return (Iterable) startNode.findAllByTraversal((Class) clazz, traversalDescription); } + + @Override + public T save(T entity) { + return (T) ((NodeBacked)entity).persist(); + } + + @Override + public Iterable save(Iterable entities) { + for (T entity : entities) { + save(entity); + } + return (Iterable) entities; + } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/RelationshipFinder.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultRelationshipGraphRepository.java similarity index 71% rename from spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/RelationshipFinder.java rename to spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultRelationshipGraphRepository.java index 886093d2b..73b1fd7b6 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/RelationshipFinder.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DefaultRelationshipGraphRepository.java @@ -14,18 +14,17 @@ * limitations under the License. */ -package org.springframework.data.graph.neo4j.finder; +package org.springframework.data.graph.neo4j.repository; import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.index.Index; import org.neo4j.graphdb.traversal.TraversalDescription; import org.springframework.data.graph.core.NodeBacked; import org.springframework.data.graph.core.RelationshipBacked; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; -public class RelationshipFinder extends AbstractFinder { +public class DefaultRelationshipGraphRepository extends AbstractGraphRepository implements RelationshipGraphRepository { - public RelationshipFinder(final Class clazz, final GraphDatabaseContext graphDatabaseContext) { + public DefaultRelationshipGraphRepository(final Class clazz, final GraphDatabaseContext graphDatabaseContext) { super(graphDatabaseContext, clazz); } @@ -38,5 +37,15 @@ public class RelationshipFinder extends AbstractFi public Iterable findAllByTraversal(final N startNode, final TraversalDescription traversalDescription) { throw new UnsupportedOperationException("Traversal not able to start at relationship"); } + + @Override + public T save(T entity) { + return entity; + } + + @Override + public Iterable save(Iterable entities) { + return (Iterable) entities; + } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/FinderFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DirectGraphRepositoryFactory.java similarity index 59% rename from spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/FinderFactory.java rename to spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DirectGraphRepositoryFactory.java index 0a91258a0..3f8450a08 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/FinderFactory.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/DirectGraphRepositoryFactory.java @@ -14,29 +14,29 @@ * limitations under the License. */ -package org.springframework.data.graph.neo4j.finder; +package org.springframework.data.graph.neo4j.repository; import org.springframework.data.graph.core.NodeBacked; import org.springframework.data.graph.core.RelationshipBacked; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; /** - * Simple Factory for {@link NodeFinder} instances. + * Simple Factory for {@link DefaultNodeGraphRepository} instances. */ -public class FinderFactory { +public class DirectGraphRepositoryFactory { private final GraphDatabaseContext graphDatabaseContext; - public FinderFactory(final GraphDatabaseContext graphDatabaseContext) { + public DirectGraphRepositoryFactory(final GraphDatabaseContext graphDatabaseContext) { this.graphDatabaseContext = graphDatabaseContext; } - public NodeFinder createNodeEntityFinder(Class clazz) { - return new NodeFinder(clazz, graphDatabaseContext); + public NodeGraphRepository createNodeEntityRepository(Class clazz) { + return new DefaultNodeGraphRepository(clazz, graphDatabaseContext); } - public RelationshipFinder createRelationshipEntityFinder(Class clazz) { - return new RelationshipFinder(clazz, graphDatabaseContext); + public RelationshipGraphRepository createRelationshipEntityRepository(Class clazz) { + return new DefaultRelationshipGraphRepository(clazz, graphDatabaseContext); } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphEntityInformation.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphEntityInformation.java new file mode 100644 index 000000000..91001f72f --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphEntityInformation.java @@ -0,0 +1,17 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.graph.core.GraphBacked; +import org.springframework.data.repository.support.EntityInformation; + +import java.io.Serializable; + +/** + * @author mh + * @since 28.03.11 + */ +public interface GraphEntityInformation> extends EntityInformation { + + boolean isNodeEntity(); + boolean isPartialEntity(); +} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphMetamodelEntityInformation.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphMetamodelEntityInformation.java new file mode 100644 index 000000000..58992b0dd --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphMetamodelEntityInformation.java @@ -0,0 +1,55 @@ +package org.springframework.data.graph.neo4j.repository; + +/** + * @author mh + * @since 28.03.11 + */ + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.graph.annotation.NodeEntity; +import org.springframework.data.graph.core.GraphBacked; +import org.springframework.data.graph.core.NodeBacked; +import org.springframework.data.graph.core.RelationshipBacked; +import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; +import org.springframework.data.repository.support.AbstractEntityInformation; + +public class GraphMetamodelEntityInformation> extends AbstractEntityInformation implements GraphEntityInformation { + + private final boolean isNodeEntity; + private final boolean isPartialEntity; + private GraphDatabaseContext graphDatabaseContext; + + public GraphMetamodelEntityInformation(Class domainClass, GraphDatabaseContext graphDatabaseContext) { + super(domainClass); + this.graphDatabaseContext = graphDatabaseContext; + NodeEntity nodeEntity = getJavaType().getAnnotation(NodeEntity.class); + isNodeEntity = nodeEntity!=null; + isPartialEntity = isNodeEntity && nodeEntity.partial(); + } + + @Override + public boolean isNodeEntity() { + return isNodeEntity; + } + + @Override + public boolean isPartialEntity() { + return isPartialEntity; + } + + @Override + public boolean isNew(T entity) { + return entity.hasPersistentState(); + } + + + @Override + public Long getId(T entity) { + return isNodeEntity() ? ((NodeBacked)entity).getNodeId() : ((RelationshipBacked)entity).getRelationshipId(); + } + + @Override + public Class getIdType() { + return Long.class; + } +} \ No newline at end of file diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepository.java new file mode 100644 index 000000000..20554705c --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepository.java @@ -0,0 +1,12 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.graph.core.GraphBacked; + +/** + * @author mh + * @since 12.01.11 + */ +public interface GraphRepository> extends CRUDGraphRepository, IndexQueryExecutor, TraversalQueryExecutor { + +} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactory.java new file mode 100644 index 000000000..7f7bc8823 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactory.java @@ -0,0 +1,91 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.springframework.data.graph.annotation.NodeEntity; +import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.QueryLookupStrategy; +import org.springframework.data.repository.query.RepositoryQuery; +import org.springframework.data.repository.support.EntityInformation; +import org.springframework.data.repository.support.RepositoryFactorySupport; +import org.springframework.data.repository.support.RepositoryMetadata; +import org.springframework.util.Assert; + +import java.io.Serializable; +import java.lang.reflect.Method; + +import static org.springframework.core.GenericTypeResolver.resolveTypeArguments; + +/** + * @author mh + * @since 28.03.11 + */ +public class GraphRepositoryFactory extends RepositoryFactorySupport { + + + private final GraphDatabaseContext graphDatabaseContext; + + public GraphRepositoryFactory(GraphDatabaseContext graphDatabaseContext) { + + Assert.notNull(graphDatabaseContext); + this.graphDatabaseContext = graphDatabaseContext; + } + + + /* + * (non-Javadoc) + * + * @see + * org.springframework.data.repository.support.RepositoryFactorySupport# + * getTargetRepository(java.lang.Class) + */ + @Override + protected Object getTargetRepository(RepositoryMetadata metadata) { + return getTargetRepository(metadata, graphDatabaseContext); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected Object getTargetRepository(RepositoryMetadata metadata, GraphDatabaseContext graphDatabaseContext) { + Class repositoryInterface = metadata.getRepositoryInterface(); + Class type = metadata.getDomainClass(); + GraphEntityInformation entityInformation = (GraphEntityInformation)getEntityInformation(type); + + if (entityInformation.isNodeEntity()) { + return new DefaultNodeGraphRepository(type,graphDatabaseContext); + } else { + return new DefaultRelationshipGraphRepository(type,graphDatabaseContext); + } + } + + private static Class getDomainClass(Class repositoryInterface) { + Class[] arguments = resolveTypeArguments(repositoryInterface, Repository.class); + return arguments == null ? null : arguments[0]; + } + + + @Override + protected Class getRepositoryBaseClass(Class repositoryInterface) { + Class domainClass = getDomainClass(repositoryInterface); + if (domainClass.isAnnotationPresent(NodeEntity.class)) { + return DefaultNodeGraphRepository.class; + } else { + return DefaultRelationshipGraphRepository.class; + } + } + + @Override + @SuppressWarnings({"unchecked"}) + public EntityInformation getEntityInformation(Class type) { + return new GraphMetamodelEntityInformation(type,graphDatabaseContext); + } + + + @Override + protected QueryLookupStrategy getQueryLookupStrategy(QueryLookupStrategy.Key key) { + return new QueryLookupStrategy(){ + @Override + public RepositoryQuery resolveQuery(Method method, Class domainClass) { + return null; + } + }; + } +} \ No newline at end of file diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactoryBean.java new file mode 100644 index 000000000..401f8a9e0 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/GraphRepositoryFactoryBean.java @@ -0,0 +1,41 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.graph.core.GraphBacked; +import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; +import org.springframework.data.repository.support.RepositoryFactorySupport; +import org.springframework.data.repository.support.TransactionalRepositoryFactoryBeanSupport; +import org.springframework.util.Assert; + +/** + * @author mh + * @since 28.03.11 + */ +public class GraphRepositoryFactoryBean, T extends GraphBacked> + extends TransactionalRepositoryFactoryBeanSupport { + + private GraphDatabaseContext graphDatabaseContext; + + public void setGraphDatabaseContext(GraphDatabaseContext graphDatabaseContext) { + this.graphDatabaseContext = graphDatabaseContext; + } + + + @Override + protected RepositoryFactorySupport doCreateRepositoryFactory() { + + return createRepositoryFactory(graphDatabaseContext); + } + + + protected RepositoryFactorySupport createRepositoryFactory(GraphDatabaseContext graphDatabaseContext) { + + return new GraphRepositoryFactory(graphDatabaseContext); + } + + @Override + public void afterPropertiesSet() { + Assert.notNull(graphDatabaseContext, "GraphDatabaseContext must not be null!"); + super.afterPropertiesSet(); + } +} \ No newline at end of file diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/IndexQueryExecutor.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/IndexQueryExecutor.java new file mode 100644 index 000000000..609291753 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/IndexQueryExecutor.java @@ -0,0 +1,18 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.PropertyContainer; +import org.springframework.data.graph.core.GraphBacked; + +/** + * @author mh + * @since 29.03.11 + */ +public interface IndexQueryExecutor> { + T findByPropertyValue(String indexName, String property, Object value); + + Iterable findAllByPropertyValue(String indexName, String property, Object value); + + Iterable findAllByQuery(String indexName, String key, Object query); + + Iterable findAllByRange(String indexName, String property, Number from, Number to); +} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/NodeGraphRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/NodeGraphRepository.java new file mode 100644 index 000000000..3563fe347 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/NodeGraphRepository.java @@ -0,0 +1,11 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.Node; +import org.springframework.data.graph.core.NodeBacked; + +/** + * @author mh + * @since 29.03.11 + */ +public interface NodeGraphRepository extends GraphRepository { +} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/RelationshipGraphRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/RelationshipGraphRepository.java new file mode 100644 index 000000000..5f0325401 --- /dev/null +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/RelationshipGraphRepository.java @@ -0,0 +1,11 @@ +package org.springframework.data.graph.neo4j.repository; + +import org.neo4j.graphdb.Relationship; +import org.springframework.data.graph.core.RelationshipBacked; + +/** + * @author mh + * @since 29.03.11 + */ +public interface RelationshipGraphRepository extends GraphRepository { +} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/Finder.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/TraversalQueryExecutor.java similarity index 53% rename from spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/Finder.java rename to spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/TraversalQueryExecutor.java index c269e7be8..407cd9603 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/finder/Finder.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/repository/TraversalQueryExecutor.java @@ -1,4 +1,4 @@ -package org.springframework.data.graph.neo4j.finder; +package org.springframework.data.graph.neo4j.repository; import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.traversal.TraversalDescription; @@ -7,21 +7,9 @@ import org.springframework.data.graph.core.NodeBacked; /** * @author mh - * @since 12.01.11 + * @since 29.03.11 */ -public interface Finder> { - long count(); - - Iterable findAll(); - - T findById(long id); - - T findByPropertyValue(String indexName, String property, Object value); - - Iterable findAllByPropertyValue(String indexName, String property, Object value); - Iterable findAllByQuery(final String indexName, String key, final Object query); - Iterable findAllByRange(final String indexName, final String property, final Number from, final Number to); - +public interface TraversalQueryExecutor> { /** * Traversal based finder that returns a lazy Iterable over the traversal results * diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/server/SpringPluginInitializer.java b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/server/SpringPluginInitializer.java index c67195855..5f5d24a94 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/server/SpringPluginInitializer.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/server/SpringPluginInitializer.java @@ -18,7 +18,7 @@ import java.util.Collection; *
  * class MyInitializer extends SpringPluginInitializer {
  *     public MyInitializer() {
- *         super(new String[]{"myContext.xml"},"finderFactory","myRepository");
+ *         super(new String[]{"myContext.xml"},"graphRepositoryFactory","myRepository");
  *     }
  * }
  * 
diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/GroupRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/GroupRepository.java new file mode 100644 index 000000000..9f18f3846 --- /dev/null +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/GroupRepository.java @@ -0,0 +1,10 @@ +package org.springframework.data.graph.neo4j; + +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; + +/** + * @author mh + * @since 29.03.11 + */ +public interface GroupRepository extends NodeGraphRepository { +} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/PersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/PersonRepository.java new file mode 100644 index 000000000..442abfed2 --- /dev/null +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/PersonRepository.java @@ -0,0 +1,10 @@ +package org.springframework.data.graph.neo4j; + +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; + +/** + * @author mh + * @since 29.03.11 + */ +public interface PersonRepository extends NodeGraphRepository { +} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest.java index 63f3bf573..f49d3364d 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/config/DataGraphNamespaceHandlerTest.java @@ -1,18 +1,13 @@ package org.springframework.data.graph.neo4j.config; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.kernel.EmbeddedGraphDatabase; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.GraphDatabaseContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.PlatformTransactionManager; /** @@ -26,7 +21,7 @@ public class DataGraphNamespaceHandlerTest { @Autowired GraphDatabaseService graphDatabaseService; @Autowired - FinderFactory finderFactory; + DirectGraphRepositoryFactory graphRepositoryFactory; @Autowired GraphDatabaseContext graphDatabaseContext; @Autowired @@ -59,7 +54,7 @@ public class DataGraphNamespaceHandlerTest { Assert.assertNotNull("graphDatabaseContext", graphDatabaseContext); EmbeddedGraphDatabase graphDatabaseService = (EmbeddedGraphDatabase) graphDatabaseContext.getGraphDatabaseService(); Assert.assertEquals("store-dir", "target/config-test", graphDatabaseService.getStoreDir()); - Assert.assertNotNull("finderFactory",config.finderFactory); + Assert.assertNotNull("graphRepositoryFactory",config.graphRepositoryFactory); Assert.assertNotNull("graphDatabaseService",config.graphDatabaseService); Assert.assertNotNull("transactionManager",config.transactionManager); config.graphDatabaseService.shutdown(); diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/AttachEntityTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/AttachEntityTest.java index a5aac202c..d9dc58f58 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/AttachEntityTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/AttachEntityTest.java @@ -8,7 +8,7 @@ import org.neo4j.graphdb.Node; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.core.NodeBacked; import org.springframework.data.graph.neo4j.Developer; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -25,17 +25,17 @@ public class AttachEntityTest { protected final Log log = LogFactory.getLog(getClass()); @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @Test @Transactional public void entityShouldHaveNoNode() { Developer dev = new Developer("Michael"); - assertFalse(hasUnderlyingNode(dev)); + assertFalse(hasPersistentState(dev)); assertNull(nodeFor(dev)); } - private boolean hasUnderlyingNode(NodeBacked nodeBacked) { + private boolean hasPersistentState(NodeBacked nodeBacked) { return nodeBacked.hasPersistentState(); } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/FinderTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/FinderTest.java index 24e961add..bb4c48fe2 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/FinderTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/FinderTest.java @@ -2,19 +2,19 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hamcrest.Matcher; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; +import org.junit.internal.matchers.IsCollectionContaining; import org.junit.runner.RunWith; import org.neo4j.helpers.collection.IteratorUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.graph.neo4j.Group; +import org.springframework.data.graph.neo4j.GroupRepository; import org.springframework.data.graph.neo4j.Person; -import static org.springframework.data.graph.neo4j.Person.persistedPerson; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.PersonRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; - import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.BeforeTransaction; @@ -24,7 +24,13 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; +import static java.util.Arrays.asList; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.internal.matchers.IsCollectionContaining.hasItems; +import static org.neo4j.helpers.collection.IteratorUtil.asCollection; +import static org.springframework.data.graph.neo4j.Person.persistedPerson; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"}) @@ -36,8 +42,10 @@ public class FinderTest { @Autowired private GraphDatabaseContext graphDatabaseContext; - @Autowired - private FinderFactory finderFactory; + @Autowired + private PersonRepository personRepository; + @Autowired + private GroupRepository groupRepository; @BeforeTransaction public void cleanDb() { @@ -49,17 +57,48 @@ public class FinderTest { public void testFinderFindAll() { Person p1 = persistedPerson("Michael", 35); Person p2 = persistedPerson("David", 25); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); - Iterable allPersons = finder.findAll(); - assertEquals(new HashSet(Arrays.asList(p1, p2)), IteratorUtil.addToCollection(allPersons.iterator(), new HashSet())); + Iterable allPersons = personRepository.findAll(); + assertThat(asCollection(allPersons), hasItems(p1, p2)); + } + + @Test + @Transactional + public void testSaveManyPeople() { + Person p1 = new Person("Michael", 35); + Person p2 = new Person("David", 25); + personRepository.save(asList(p1,p2)); + assertEquals("persisted person 1",true,p1.hasPersistentState()); + assertEquals("persisted person 2",true,p2.hasPersistentState()); + assertThat(asCollection(personRepository.findAll()), hasItems(p2, p1)); + } + + @Test + @Transactional + public void testSavePerson() { + Person p1 = new Person("Michael", 35); + personRepository.save(p1); + assertEquals("persisted person",true,p1.hasPersistentState()); + assertThat(personRepository.findOne(p1.getId()),is(p1)); + } + @Test + public void testDeletePerson() { + Person p1 = persistedPerson("Michael", 35); + personRepository.delete(p1); + assertEquals("people deleted", false, personRepository.findAll().iterator().hasNext()); + } + @Test + public void testDeletePeople() { + Person p1 = persistedPerson("Michael", 35); + Person p2 = persistedPerson("David", 26); + personRepository.delete(asList(p1,p2)); + assertEquals("people deleted", false, personRepository.findAll().iterator().hasNext()); } @Test @Transactional public void testFinderFindById() { Person p = persistedPerson("Michael", 35); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); - Person pById = finder.findById(p.getNodeId()); + Person pById = personRepository.findOne(p.getNodeId()); assertEquals(p, pById); } @@ -67,19 +106,18 @@ public class FinderTest { @Transactional public void testFinderFindByIdNonexistent() { Person p = persistedPerson("Michael", 35); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); - Person p2 = finder.findById(589736218); + Person p2 = personRepository.findOne(589736218L); Assert.assertNull(p2); } @Test @Transactional public void testFinderCount() { - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); - assertEquals(0, finder.count()); + assertEquals((Long)0L, personRepository.count()); Person p = persistedPerson("Michael", 35); - assertEquals(1, finder.count()); + assertEquals((Long)1L, personRepository.count()); } + @Test @Transactional public void testFindAllOnGroup() { @@ -88,8 +126,7 @@ public class FinderTest { g.setName("test"); Group g2 = new Group().persist(); g.setName("test"); - final NodeFinder finder = finderFactory.createNodeEntityFinder(Group.class); - Collection groups = IteratorUtil.addToCollection(finder.findAll().iterator(), new HashSet()); + Collection groups = IteratorUtil.addToCollection(groupRepository.findAll().iterator(), new HashSet()); Assert.assertEquals(2, groups.size()); log.debug("FindAllOnGroup done"); } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexTest.java index dd9e9244b..a794f76b5 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/IndexTest.java @@ -4,7 +4,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.neo4j.graphdb.DynamicRelationshipType; @@ -19,9 +18,9 @@ import org.springframework.data.graph.annotation.NodeEntity; import org.springframework.data.graph.neo4j.Friendship; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; -import org.springframework.data.graph.neo4j.finder.RelationshipFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; +import org.springframework.data.graph.neo4j.repository.RelationshipGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -49,14 +48,14 @@ public class IndexTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; - protected NodeFinder groupFinder; - protected NodeFinder personFinder; + private DirectGraphRepositoryFactory graphRepositoryFactory; + protected NodeGraphRepository groupFinder; + protected NodeGraphRepository personFinder; @Before public void setUp() throws Exception { - groupFinder = finderFactory.createNodeEntityFinder(Group.class); - personFinder = finderFactory.createNodeEntityFinder(Person.class); + groupFinder = graphRepositoryFactory.createNodeEntityRepository(Group.class); + personFinder = graphRepositoryFactory.createNodeEntityRepository(Person.class); } @BeforeTransaction @@ -71,7 +70,7 @@ public class IndexTest { Person p2 = persistedPerson(NAME_VALUE2, 25); Friendship friendship = p.knows(p2); friendship.setYears(1); - RelationshipFinder friendshipFinder = finderFactory.createRelationshipEntityFinder(Friendship.class); + RelationshipGraphRepository friendshipFinder = graphRepositoryFactory.createRelationshipEntityRepository(Friendship.class); assertEquals(friendship, friendshipFinder.findByPropertyValue(null, "Friendship.years", 1)); } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ModificationOutsideOfTransactionTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ModificationOutsideOfTransactionTest.java index 9361722f1..5f05bc4b9 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ModificationOutsideOfTransactionTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ModificationOutsideOfTransactionTest.java @@ -10,8 +10,8 @@ import org.neo4j.graphdb.Node; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -37,7 +37,7 @@ public class ModificationOutsideOfTransactionTest private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @Before public void cleanDb() { @@ -49,7 +49,7 @@ public class ModificationOutsideOfTransactionTest assertEquals(35, p.getAge()); p.setAge(36); assertEquals(36, p.getAge()); - assertFalse(hasUnderlyingNode(p)); + assertFalse(hasPersistentState(p)); p.persist(); assertEquals(36, nodeFor(p).getProperty("Person.age")); } @@ -63,8 +63,8 @@ public class ModificationOutsideOfTransactionTest michael.setBoss(emil); assertEquals(emil, michael.getBoss()); - assertFalse(hasUnderlyingNode(michael)); - assertFalse(hasUnderlyingNode(emil)); + assertFalse(hasPersistentState(michael)); + assertFalse(hasPersistentState(emil)); michael.persist(); assertThat(nodeFor(michael), hasRelationship("boss", nodeFor(emil))); assertThat(nodeFor(emil), hasRelationship("boss", nodeFor(michael))); @@ -80,8 +80,8 @@ public class ModificationOutsideOfTransactionTest michael.setBoss(emil); assertEquals(emil, michael.getBoss()); - assertFalse(hasUnderlyingNode(michael)); - assertFalse(hasUnderlyingNode(emil)); + assertFalse(hasPersistentState(michael)); + assertFalse(hasPersistentState(emil)); emil.persist(); assertThat(nodeFor(michael), hasRelationship("boss", nodeFor(emil))); assertThat(nodeFor(emil), hasRelationship("boss", nodeFor(michael))); @@ -159,7 +159,7 @@ public class ModificationOutsideOfTransactionTest assertEquals( spouse2, p.getSpouse() ); } - private boolean hasUnderlyingNode( Person person ) + private boolean hasPersistentState( Person person ) { return person.hasPersistentState(); } @@ -179,7 +179,7 @@ public class ModificationOutsideOfTransactionTest @Test public void testFindOutsideTransaction() { - final NodeFinder finder = finderFactory.createNodeEntityFinder( Person.class ); + final NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Person.class); assertEquals( false, finder.findAll().iterator().hasNext() ); } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityInstantiationTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityInstantiationTest.java index 6fcf2f86a..403f8ec4b 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityInstantiationTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityInstantiationTest.java @@ -2,18 +2,13 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.NotFoundException; -import org.neo4j.graphdb.Transaction; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.graph.core.NodeBacked; -import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.CleanContextCacheTestExecutionListener; import org.springframework.test.context.ContextConfiguration; @@ -41,7 +36,7 @@ import static org.springframework.data.graph.neo4j.Person.persistedPerson; private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { @@ -60,8 +55,8 @@ import static org.springframework.data.graph.neo4j.Person.persistedPerson; Person person2 = graphDatabaseContext.createEntityFromState(node,Person.class); assertEquals("Rod", person2.getName()); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); - Person found = finder.findById(nodeId); + NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Person.class); + Person found = finder.findOne(nodeId); assertEquals("Rod", found.getName()); } } diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityRelationshipTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityRelationshipTest.java index 2f77f4bb4..1b5ced614 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityRelationshipTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityRelationshipTest.java @@ -3,7 +3,6 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.neo4j.graphdb.*; @@ -14,7 +13,7 @@ import org.springframework.data.graph.neo4j.Friendship; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; import static org.springframework.data.graph.neo4j.Person.persistedPerson; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.ContextConfiguration; @@ -37,7 +36,7 @@ public class NodeEntityRelationshipTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityTest.java index 0324d897f..b2f94e749 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/NodeEntityTest.java @@ -10,8 +10,8 @@ import org.neo4j.graphdb.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -32,7 +32,7 @@ import static org.springframework.data.graph.neo4j.Person.persistedPerson; private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { @@ -93,7 +93,7 @@ import static org.springframework.data.graph.neo4j.Person.persistedPerson; tx.success(); tx.finish(); Assert.assertNull("spouse removed " + p.getSpouse(), p.getSpouse()); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); + NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Person.class); Person spouseFromIndex = finder.findByPropertyValue(Person.NAME_INDEX, "name", "Tina"); Assert.assertNull("spouse not found in index",spouseFromIndex); Assert.assertNull("node deleted " + id, graphDatabaseContext.getNodeById(id)); @@ -110,7 +110,7 @@ import static org.springframework.data.graph.neo4j.Person.persistedPerson; tx.success(); tx.finish(); Assert.assertNull("spouse removed " + p.getSpouse(), p.getSpouse()); - NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); + NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Person.class); Person spouseFromIndex = finder.findByPropertyValue(Person.NAME_INDEX, "name", "Tina"); Assert.assertNull("spouse not found in index", spouseFromIndex); Assert.assertNull("node deleted " + id, graphDatabaseContext.getNodeById(id)); diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ProjectionTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ProjectionTest.java index bbe056c92..c21ea100b 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ProjectionTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/ProjectionTest.java @@ -2,16 +2,14 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Named; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; -import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.BeforeTransaction; @@ -30,7 +28,7 @@ public class ProjectionTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/PropertyTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/PropertyTest.java index 917a732cc..dd5bc9e65 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/PropertyTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/PropertyTest.java @@ -8,7 +8,7 @@ import org.neo4j.graphdb.NotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.graph.neo4j.*; -import org.springframework.data.graph.neo4j.finder.FinderFactory; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ContextConfiguration; @@ -32,7 +32,7 @@ public class PropertyTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/RelationshipEntityTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/RelationshipEntityTest.java index ba56d71af..3f6f537d4 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/RelationshipEntityTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/RelationshipEntityTest.java @@ -2,7 +2,6 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.neo4j.graphdb.*; @@ -11,7 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.neo4j.Friendship; import org.springframework.data.graph.neo4j.Person; import static org.springframework.data.graph.neo4j.Person.persistedPerson; -import org.springframework.data.graph.neo4j.finder.FinderFactory; + +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.ContextConfiguration; @@ -32,7 +32,7 @@ public class RelationshipEntityTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/SubReferenceNodeTypeStrategyTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/SubReferenceNodeTypeStrategyTest.java index f75bf0760..4ecc4184e 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/SubReferenceNodeTypeStrategyTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/SubReferenceNodeTypeStrategyTest.java @@ -19,8 +19,8 @@ import org.springframework.data.graph.neo4j.Person; import static org.springframework.data.graph.neo4j.Person.persistedPerson; import org.springframework.data.graph.neo4j.Toyota; import org.springframework.data.graph.neo4j.Volvo; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.context.CleanContextCacheTestExecutionListener; @@ -51,7 +51,7 @@ public class SubReferenceNodeTypeStrategyTest { @Autowired GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @Autowired private SubReferenceTypeRepresentationStrategy nodeTypeStrategy; private Node thingNode; @@ -166,7 +166,7 @@ public class SubReferenceNodeTypeStrategyTest { public void testInstantiateConcreteClassWithFinder() { log.debug("testInstantiateConcreteClassWithFinder"); Volvo v=new Volvo().persist(); - NodeFinder finder = finderFactory.createNodeEntityFinder(Car.class); + NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Car.class); assertEquals("Wrong concrete class.", Volvo.class, finder.findAll().iterator().next().getClass()); } @@ -178,16 +178,16 @@ public class SubReferenceNodeTypeStrategyTest { log.warn("Created volvo"); new Toyota().persist(); log.warn("Created volvo"); - assertEquals("Wrong count for Volvo.", 1, finderFactory.createNodeEntityFinder(Volvo.class).count()); - assertEquals("Wrong count for Toyota.", 1, finderFactory.createNodeEntityFinder(Toyota.class).count()); - assertEquals("Wrong count for Car.", 2, finderFactory.createNodeEntityFinder(Car.class).count()); + assertEquals("Wrong count for Volvo.", (Long)1L, graphRepositoryFactory.createNodeEntityRepository(Volvo.class).count()); + assertEquals("Wrong count for Toyota.", (Long)1L, graphRepositoryFactory.createNodeEntityRepository(Toyota.class).count()); + assertEquals("Wrong count for Car.", (Long)2L, graphRepositoryFactory.createNodeEntityRepository(Car.class).count()); } @Test @Transactional public void testCountClasses() { persistedPerson("Michael", 36); persistedPerson("David", 25); - assertEquals("Wrong Person instance count.", 2, finderFactory.createNodeEntityFinder(Person.class).count()); + assertEquals("Wrong Person instance count.", (Long)2L, graphRepositoryFactory.createNodeEntityRepository(Person.class).count()); } @NodeEntity diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/TraversalTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/TraversalTest.java index 2e64b6e80..a342e9dc2 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/TraversalTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/neo4j/support/TraversalTest.java @@ -2,7 +2,6 @@ package org.springframework.data.graph.neo4j.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.neo4j.graphdb.DynamicRelationshipType; @@ -13,8 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.graph.neo4j.Group; import org.springframework.data.graph.neo4j.Person; import static org.springframework.data.graph.neo4j.Person.persistedPerson; -import org.springframework.data.graph.neo4j.finder.FinderFactory; -import org.springframework.data.graph.neo4j.finder.NodeFinder; + +import org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory; +import org.springframework.data.graph.neo4j.repository.NodeGraphRepository; import org.springframework.data.graph.neo4j.support.node.Neo4jHelper; import org.springframework.test.annotation.Rollback; @@ -39,7 +39,7 @@ public class TraversalTest { private GraphDatabaseContext graphDatabaseContext; @Autowired - private FinderFactory finderFactory; + private DirectGraphRepositoryFactory graphRepositoryFactory; @BeforeTransaction public void cleanDb() { @@ -81,7 +81,7 @@ public class TraversalTest { @Test @Transactional public void testTraverseFromGroupToPeopleWithFinder() { - final NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); + final NodeGraphRepository finder = graphRepositoryFactory.createNodeEntityRepository(Person.class); Person p = persistedPerson("Michael", 35); Group group = new Group().persist(); group.setName("dev"); diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/partial/Neo4jGraphRecommendationTest-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/partial/Neo4jGraphRecommendationTest-context.xml index 43b2288e9..4f34a5895 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/partial/Neo4jGraphRecommendationTest-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/partial/Neo4jGraphRecommendationTest-context.xml @@ -115,21 +115,21 @@ - + - +
- + - + diff --git a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml index b8c13e80a..795230685 100644 --- a/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml +++ b/spring-data-neo4j/src/test/resources/org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml @@ -109,19 +109,19 @@ - + - + - + - + @@ -139,4 +139,21 @@ + + + + + + + + + + + + + + + + + diff --git a/src/docbkx/reference/neo4j-server.xml b/src/docbkx/reference/neo4j-server.xml index 07826bc84..b590f2a31 100644 --- a/src/docbkx/reference/neo4j-server.xml +++ b/src/docbkx/reference/neo4j-server.xml @@ -42,7 +42,7 @@ org.neo4j.server.thirdparty_jaxrs_classes=com.example.mypackage=/my-context by the spring context but already provided by the Neo4j-server. But a correctly set up and loaded spring context ist the requirement for spring data graph to work. By using the lifecycle support of Neo4j server extendsions it is possible to register the provided graph database with the - spring configuration and also to expose certain spring beans (e.g. finderFactory, graphDatabaseContext) to be + spring configuration and also to expose certain spring beans (e.g. graphRepositoryFactory, graphDatabaseContext) to be injected via jersey into subsequent resources. @@ -52,7 +52,7 @@ org.neo4j.server.thirdparty_jaxrs_classes=com.example.mypackage=/my-context diff --git a/src/docbkx/reference/programming-model/aspectj.xml b/src/docbkx/reference/programming-model/aspectj.xml index 318318307..6b8094c71 100644 --- a/src/docbkx/reference/programming-model/aspectj.xml +++ b/src/docbkx/reference/programming-model/aspectj.xml @@ -16,7 +16,7 @@ The aspect introduces some internal fields and some public methods () to the entities for accessing the backing state via getPersistentState() and creating relationships with relateTo - and retrieving relationship entities via getRelationshipTo. It also introduces finder methods like + and retrieving relationship entities via getRelationshipTo. It also introduces graphRepository methods like find(Class<? extends NodeEntity>, TraversalDescription) and equals and hashCode delegation. diff --git a/src/docbkx/reference/programming-model/finders.xml b/src/docbkx/reference/programming-model/finders.xml index 3d17be1de..4502c538a 100644 --- a/src/docbkx/reference/programming-model/finders.xml +++ b/src/docbkx/reference/programming-model/finders.xml @@ -43,21 +43,21 @@ The Finder instances are created via a FinderFactory to be bound to a concrete node or relationship entity class. The FinderFactory is configured in the Spring context and can be injected. finder = finderFactory.createNodeEntityFinder(Person.class); +NodeFinder graphRepository = graphRepositoryFactory.createNodeEntityFinder(Person.class); -Person dave=finder.findById(123); +Person dave=graphRepository.findById(123); -long numberOfPeople = finder.count(); +long numberOfPeople = graphRepository.count(); -Person mark = finder.findByPropertyValue(null,"name", "mark"); +Person mark = graphRepository.findByPropertyValue(null,"name", "mark"); -Iterable devs = finder.findAllByProperyValue(null, "occupation","developer"); +Iterable devs = graphRepository.findAllByProperyValue(null, "occupation","developer"); -Iterable middleAgedPeople = finder.findAllByRange(null, "age",20,40); +Iterable middleAgedPeople = graphRepository.findAllByRange(null, "age",20,40); -Iterable aTeam = finder.findAllByQuery(null, "name","A*"); +Iterable aTeam = graphRepository.findAllByQuery(null, "name","A*"); -Iterable davesFriends = finder.findAllByTraversal(dave, +Iterable davesFriends = graphRepository.findAllByTraversal(dave, Traversal.description().pruneAfterDepth(1) .relationships(KNOWS).filter(returnAllButStartNode())); ]]> diff --git a/src/docbkx/reference/programming-model/indexing.xml b/src/docbkx/reference/programming-model/indexing.xml index 896a1a329..bb9c4fe4b 100644 --- a/src/docbkx/reference/programming-model/indexing.xml +++ b/src/docbkx/reference/programming-model/indexing.xml @@ -27,7 +27,7 @@ Query access to the index happens with the Node- and RelationshipFinders that are created via an instance of - org.springframework.data.graph.neo4j.finder.FinderFactory. The methods + org.springframework.data.graph.neo4j.repository.DirectGraphRepositoryFactory. The methods findByPropertyValue and findAllByPropertyValue work on the exact indexes and return the first or all matches. To do range queries, use findAllByRange (please note that currently both values are inclusive). @@ -44,13 +44,13 @@ class Person { } -NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); +NodeFinder graphRepository = graphRepositoryFactory.createNodeEntityFinder(Person.class); -// exact finder -Person mark = finder.findByProperyValue("people","name","mark"); +// exact graphRepository +Person mark = graphRepository.findByProperyValue("people","name","mark"); // numeric range queries -for (Person middleAgedDeveloper : finder.findAllByRange(null, "age", 20, 40)) { +for (Person middleAgedDeveloper : graphRepository.findAllByRange(null, "age", 20, 40)) { Developer developer=middleAgedDeveloper.projectTo(Developer.class); } ]]> @@ -76,10 +76,10 @@ class Person { String name; } -NodeFinder finder = finderFactory.createNodeEntityFinder(Person.class); +NodeFinder graphRepository = graphRepositoryFactory.createNodeEntityFinder(Person.class); -// exact finder -Person mark = finder.findAllByQuery("people-search","name","ma*"); +// exact graphRepository +Person mark = graphRepository.findAllByQuery("people-search","name","ma*"); ]]> diff --git a/src/docbkx/reference/programming-model/projection.xml b/src/docbkx/reference/programming-model/projection.xml index 6d6a7068e..ea061379f 100644 --- a/src/docbkx/reference/programming-model/projection.xml +++ b/src/docbkx/reference/programming-model/projection.xml @@ -33,7 +33,7 @@ class Trainee { Set trainings; } -for (Person person : finder.findAllByProperyValue("occupation","developer")) { +for (Person person : graphRepository.findAllByProperyValue("occupation","developer")) { Developer developer = person.projectTo(Developer.class); if (developer.isJavaDeveloper()) { trainInSpringData(developer.projectTo(Trainee.class)); diff --git a/src/docbkx/tutorial/indexing.xml b/src/docbkx/tutorial/indexing.xml index 1fcc294b0..ff72037c9 100644 --- a/src/docbkx/tutorial/indexing.xml +++ b/src/docbkx/tutorial/indexing.xml @@ -18,12 +18,12 @@ class Movie { int year; } -@Autowired FinderFactory finderFactory; +@Autowired FinderFactory graphRepositoryFactory; @Test [@Transactional] public void persistedMovieShouldBeRetrievableFromGraphDb() { int id=1; Movie forrestGump = new Movie(id, "Forrest Gump", 1994).persist(); - NodeFinder movieFinder = finderFactory.createNodeEntityFinder(Movie.class); + NodeFinder movieFinder = graphRepositoryFactory.createNodeEntityFinder(Movie.class); // REMINDER, the "null" stands for an optional index name Movie retrievedMovie = movieFinder.findByPropertyValue(null, "id",id); assertEqual("retrieved movie matches persisted one",forrestGump,retrievedMovie); diff --git a/src/docbkx/tutorial/repository.xml b/src/docbkx/tutorial/repository.xml index 817ae3c75..c6a0e521c 100644 --- a/src/docbkx/tutorial/repository.xml +++ b/src/docbkx/tutorial/repository.xml @@ -10,12 +10,12 @@ movieFinder; @Autowired - public CineastsRepostory(FinderFactory finderFactory) { - this.finderFactory = finderFactory; - this.movieFinder = finderFactory.createNodeEntityFinder(Movie.class); + public CineastsRepostory(FinderFactory graphRepositoryFactory) { + this.graphRepositoryFactory = graphRepositoryFactory; + this.movieFinder = graphRepositoryFactory.createNodeEntityFinder(Movie.class); } public Movie getMovie(int id) { return movieFinder.findByPropertyValue(null,"id", id); diff --git a/src/docbkx/tutorial/security.xml b/src/docbkx/tutorial/security.xml index 21ab82364..b23d4bb1c 100644 --- a/src/docbkx/tutorial/security.xml +++ b/src/docbkx/tutorial/security.xml @@ -90,12 +90,12 @@ in a separate applicationContext-security.xml. But first, as always, Maven and w @Service public class CineastsUserDetailsService implements UserDetailsService, InitializingBean { - @Autowired private FinderFactory finderFactory; + @Autowired private FinderFactory graphRepositoryFactory; private NodeFinder userFinder; @Override public void afterPropertiesSet() throws Exception { - userFinder = finderFactory.createNodeEntityFinder(User.class); + userFinder = graphRepositoryFactory.createNodeEntityFinder(User.class); } @Override diff --git a/src/docbkx/tutorial/webapp.xml b/src/docbkx/tutorial/webapp.xml index e415c6232..eceaad753 100644 --- a/src/docbkx/tutorial/webapp.xml +++ b/src/docbkx/tutorial/webapp.xml @@ -35,7 +35,7 @@ lucene we were delighted to see that fulltext indexes are supported out of the b We happily annotated the title field of my Movie class with @Index(fulltext=true) and was told with an exception that we have to specify a separate index name for that. -So it became @Indexed(fulltext = true, indexName = "search"). The corresponding finder method is called findAllByQuery. So there was our second repository method for +So it became @Indexed(fulltext = true, indexName = "search"). The corresponding graphRepository method is called findAllByQuery. So there was our second repository method for searching movies. To restrict the size of the returned set we just added a limit for now that truncates the result after so many entries.