DATAGRAPH-384 Upgrade to Neo4j 2.0
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Data Neo4j - Parent</name>
|
||||
@@ -34,10 +34,10 @@
|
||||
<dist.id>spring-data-neo4j</dist.id>
|
||||
|
||||
<springdata.commons>1.7.0.BUILD-SNAPSHOT</springdata.commons>
|
||||
<neo4j.version>1.9.4</neo4j.version>
|
||||
<neo4j.version>2.0.0-M05</neo4j.version>
|
||||
|
||||
<neo4j.spatial.version>0.11-neo4j-1.9</neo4j.spatial.version>
|
||||
<neo4j.graph-collections.version>0.6-neo4j-1.9</neo4j.graph-collections.version>
|
||||
<neo4j.spatial.version>0.12-neo4j-2.0.0-SNAPSHOT</neo4j.spatial.version>
|
||||
<neo4j.graph-collections.version>0.7-neo4j-2.0.0-SNAPSHOT</neo4j.graph-collections.version>
|
||||
<blueprints.version>1.2</blueprints.version>
|
||||
<gremlin.version>1.5</gremlin.version>
|
||||
<pipes.version>1.5</pipes.version>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -97,12 +97,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@@ -148,7 +148,7 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tinkerpop.blueprints</groupId>
|
||||
<artifactId>blueprints-core</artifactId>
|
||||
@@ -174,14 +174,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tinkerpop.gremlin</groupId>
|
||||
<artifactId>gremlin-groovy</artifactId>
|
||||
<version>${gremlin.version}</version>
|
||||
<optional>true</optional>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -31,9 +31,11 @@ import org.springframework.data.neo4j.aspects.Person;
|
||||
import org.springframework.data.neo4j.aspects.Toyota;
|
||||
import org.springframework.data.neo4j.aspects.Volvo;
|
||||
import org.springframework.data.neo4j.aspects.support.EntityTestBase;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.repository.GraphRepository;
|
||||
import org.springframework.data.neo4j.support.mapping.EntityStateHandler;
|
||||
import org.springframework.data.neo4j.support.typerepresentation.SubReferenceNodeTypeRepresentationStrategy;
|
||||
import org.springframework.data.neo4j.template.GraphCallback;
|
||||
import org.springframework.test.context.CleanContextCacheTestExecutionListener;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
@@ -82,6 +84,7 @@ public class SubReferenceNodeTypeRepresentationStrategyTests extends EntityTestB
|
||||
assertEquals("one thing has been created", 2, typeNode.getProperty(SubReferenceNodeTypeRepresentationStrategy.SUBREFERENCE_NODE_COUNTER_KEY));
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Transactional
|
||||
public void gettingTypeFromNonTypeNodeShouldThrowAnDescriptiveException() throws Exception {
|
||||
Node referenceNode = neo4jTemplate.getReferenceNode();
|
||||
nodeTypeRepresentationStrategy.readAliasFrom(referenceNode);
|
||||
@@ -219,12 +222,21 @@ public class SubReferenceNodeTypeRepresentationStrategyTests extends EntityTestB
|
||||
|
||||
@Test
|
||||
public void testSaveTwice() throws Exception {
|
||||
Thing thing = new Thing();
|
||||
thing.setName("Foo");
|
||||
thing = neo4jTemplate.save(thing);
|
||||
thing.setName("Bar");
|
||||
thing = neo4jTemplate.save(thing);
|
||||
neo4jTemplate.findOne(thing.getNodeId(),Thing.class);
|
||||
final Thing thing = neo4jTemplate.exec(new GraphCallback<Thing>() {
|
||||
|
||||
public Thing doWithGraph(GraphDatabase graph) throws Exception {
|
||||
Thing thing = new Thing();
|
||||
thing.setName("Foo");
|
||||
return neo4jTemplate.save(thing);
|
||||
}
|
||||
});
|
||||
neo4jTemplate.exec(new GraphCallback.WithoutResult() {
|
||||
public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
|
||||
thing.setName("Bar");
|
||||
Thing found = neo4jTemplate.save(thing);
|
||||
neo4jTemplate.findOne(found.getNodeId(),Thing.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -52,25 +52,25 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-tx</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-distribution</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
<name>Spring Data Neo4j - Rest Binding</name>
|
||||
<description>pring Data Neo4j Wrapper for the Neo4j REST API, provides a Graph Database proxy for the remote invocation.</description>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<validation>1.0.0.GA</validation>
|
||||
<jersey.version>1.4</jersey.version>
|
||||
<neo4j-rest-graphdb.version>1.9</neo4j-rest-graphdb.version>
|
||||
<neo4j-rest-graphdb.version>2.0-SNAPSHOT</neo4j-rest-graphdb.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.neo4j</groupId>
|
||||
@@ -127,7 +127,7 @@
|
||||
<dependency>
|
||||
<groupId>org.neo4j.server.plugin</groupId>
|
||||
<artifactId>neo4j-gremlin-plugin</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
<version>1.9.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@@ -248,14 +248,14 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
@@ -263,7 +263,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
|
||||
@@ -70,10 +70,6 @@ public class SpringPluginInitializerTests extends SpringPluginInitializer implem
|
||||
public void setUp() throws Exception {
|
||||
ImpermanentGraphDatabase db = new ImpermanentGraphDatabase();
|
||||
final ServerConfigurator configurator = new ServerConfigurator(db) {
|
||||
@Override
|
||||
public Set<ThirdPartyJaxRsPackage> getThirdpartyJaxRsClasses() {
|
||||
return Collections.singleton(new ThirdPartyJaxRsPackage("org.springframework.data.neo4j.rest.support","/test"));
|
||||
}
|
||||
@Override
|
||||
public Set<ThirdPartyJaxRsPackage> getThirdpartyJaxRsPackages() {
|
||||
return Collections.singleton(new ThirdPartyJaxRsPackage("org.springframework.data.neo4j.rest.support","/test"));
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<name>Spring Data Neo4j - Transactions</name>
|
||||
<description>External transaction manager support for Spring Data Neo4j</description>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.data.neo4j.transaction;
|
||||
|
||||
import org.neo4j.kernel.api.KernelAPI;
|
||||
import org.neo4j.kernel.api.KernelTransaction;
|
||||
import org.neo4j.kernel.impl.core.TransactionState;
|
||||
import org.neo4j.kernel.impl.transaction.AbstractTransactionManager;
|
||||
import org.neo4j.kernel.impl.transaction.TransactionStateFactory;
|
||||
@@ -25,6 +27,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.jta.JtaTransactionManager;
|
||||
|
||||
import javax.transaction.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
@@ -39,7 +42,9 @@ class SpringServiceImpl extends AbstractTransactionManager
|
||||
private TransactionManager delegate;
|
||||
|
||||
private final Map<Transaction, TransactionState> states = new WeakHashMap<Transaction, TransactionState>();
|
||||
private final Map<Transaction, KernelTransaction> kernelTransactions = new WeakHashMap<Transaction, KernelTransaction>();
|
||||
private final TransactionStateFactory stateFactory;
|
||||
private KernelAPI kernelAPI;
|
||||
|
||||
SpringServiceImpl(TransactionStateFactory stateFactory)
|
||||
{
|
||||
@@ -92,6 +97,7 @@ class SpringServiceImpl extends AbstractTransactionManager
|
||||
delegate.begin();
|
||||
Transaction tx = getTransaction();
|
||||
states.put(tx, stateFactory.create(tx));
|
||||
kernelTransactions.put( tx, kernelAPI.newTransaction() );
|
||||
}
|
||||
|
||||
public void commit() throws RollbackException, HeuristicMixedException,
|
||||
@@ -156,4 +162,24 @@ class SpringServiceImpl extends AbstractTransactionManager
|
||||
public void setTransactionManager(PlatformTransactionManager transactionManager) {
|
||||
this.transactionManager = transactionManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKernel(KernelAPI kernelAPI) {
|
||||
this.kernelAPI = kernelAPI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KernelTransaction getKernelTransaction()
|
||||
{
|
||||
Transaction transaction;
|
||||
try
|
||||
{
|
||||
transaction = getTransaction();
|
||||
}
|
||||
catch ( SystemException e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return kernelTransactions.get( transaction );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.junit.Test;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.NotFoundException;
|
||||
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
|
||||
import org.neo4j.kernel.AbstractGraphDatabase;
|
||||
import org.neo4j.kernel.configuration.Config;
|
||||
import org.objectweb.jotm.Current;
|
||||
@@ -68,8 +69,15 @@ public class JOTMIntegrationTests {
|
||||
} finally {
|
||||
transaction.finish();
|
||||
}
|
||||
Node readBackOutsideOfTx = gds.getNodeById(node.getId());
|
||||
Assert.assertEquals(node, readBackOutsideOfTx);
|
||||
|
||||
transaction = gds.beginTx();
|
||||
try {
|
||||
Node readBackOutsideOfTx = gds.getNodeById(node.getId());
|
||||
Assert.assertEquals(node, readBackOutsideOfTx);
|
||||
} finally {
|
||||
transaction.success();
|
||||
transaction.finish();
|
||||
}
|
||||
try {
|
||||
transaction = gds.beginTx();
|
||||
Node readBackInsideOfTx = gds.getNodeById(node.getId());
|
||||
@@ -91,8 +99,14 @@ public class JOTMIntegrationTests {
|
||||
} finally {
|
||||
transaction.finish();
|
||||
}
|
||||
Node retrievedNode = gds.index().forNodes("node").get("name", "value").getSingle();
|
||||
Assert.assertEquals(node, retrievedNode);
|
||||
transaction = gds.beginTx();
|
||||
try {
|
||||
Node retrievedNode = gds.index().forNodes("node").get("name", "value").getSingle();
|
||||
Assert.assertEquals(node, retrievedNode);
|
||||
} finally {
|
||||
transaction.success();
|
||||
transaction.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = NotFoundException.class)
|
||||
@@ -106,13 +120,19 @@ public class JOTMIntegrationTests {
|
||||
} finally {
|
||||
tx.finish();
|
||||
}
|
||||
gds.getNodeById(nodeId);
|
||||
tx = gds.beginTx();
|
||||
try {
|
||||
gds.getNodeById(nodeId);
|
||||
} finally {
|
||||
tx.success();
|
||||
tx.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void databaseConfiguredWithSpringJtaShouldUseJtaTransactionManager() throws SystemException, NotSupportedException {
|
||||
final Config config = ((AbstractGraphDatabase) gds).getKernelData().getConfig();
|
||||
Assert.assertEquals("spring-jta", config.getParams().get(Config.TXMANAGER_IMPLEMENTATION));
|
||||
Assert.assertEquals("spring-jta", config.getParams().get(GraphDatabaseSettings.tx_manager_impl.name()));
|
||||
|
||||
JtaTransactionManager tm = ctx.getBean("transactionManager", JtaTransactionManager.class);
|
||||
Transaction transaction = tm.createTransaction("jotm", 1000);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-parent</artifactId>
|
||||
<version>2.4.0.BUILD-SNAPSHOT</version>
|
||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.data.neo4j.config;
|
||||
|
||||
import antlr.StringUtils;
|
||||
import org.neo4j.kernel.EmbeddedGraphDatabase;
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -29,8 +28,6 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
import org.springframework.data.neo4j.annotation.NodeEntity;
|
||||
import org.springframework.data.neo4j.annotation.RelationshipEntity;
|
||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
|
||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
||||
@@ -21,8 +21,10 @@ import org.neo4j.helpers.collection.IteratorUtil;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.neo4j.conversion.EndResult;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.support.Neo4jTemplate;
|
||||
import org.springframework.data.neo4j.support.query.QueryEngine;
|
||||
import org.springframework.data.neo4j.template.GraphCallback;
|
||||
import org.springframework.data.repository.query.Parameter;
|
||||
import org.springframework.data.repository.query.ParameterAccessor;
|
||||
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||
@@ -74,11 +76,16 @@ abstract class GraphRepositoryQuery implements RepositoryQuery, ParameterResolve
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(Object[] parameters) {
|
||||
final ParameterAccessor accessor = new ParametersParameterAccessor(queryMethod.getParameters(), parameters);
|
||||
Map<String, Object> params = resolveParams(accessor);
|
||||
final String queryString = createQueryWithPagingAndSorting(accessor);
|
||||
return dispatchQuery(queryString, params, accessor);
|
||||
public Object execute(final Object[] parameters) {
|
||||
return template.exec(new GraphCallback<Object>() {
|
||||
@Override
|
||||
public Object doWithGraph(GraphDatabase graph) throws Exception {
|
||||
final ParameterAccessor accessor = new ParametersParameterAccessor(queryMethod.getParameters(), parameters);
|
||||
Map<String, Object> params = resolveParams(accessor);
|
||||
final String queryString = createQueryWithPagingAndSorting(accessor);
|
||||
return dispatchQuery(queryString, params, accessor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected Map<String, Object> resolveParams(ParameterAccessor accessor) {
|
||||
|
||||
@@ -50,9 +50,9 @@ public abstract class QueryTemplates {
|
||||
static final String SKIP_LIMIT = " SKIP %d LIMIT %d";
|
||||
static final String START_CLAUSE_INDEX_LOOKUP = "`%s`=node:`%s`(`%s`=" + PLACEHOLDER + ")";
|
||||
static final String START_CLAUSE_INDEX_QUERY = "`%s`=node:`%s`(" + PLACEHOLDER + ")";
|
||||
static final String WHERE_CLAUSE_1 = "`%1$s`.`%2$s`! %3$s {%4$d}";
|
||||
static final String WHERE_CLAUSE_1 = "`%1$s`.`%2$s` %3$s {%4$d}";
|
||||
static final String WHERE_TYPE_CHECK = "(has(`%1$s`.__type__) AND `%1$s`.__type__ IN [%2$s])";
|
||||
static final String WHERE_CLAUSE_0 = "`%1$s`.`%2$s`! %3$s ";
|
||||
static final String WHERE_CLAUSE_0 = "`%1$s`.`%2$s` %3$s ";
|
||||
static final String SORT_CLAUSE = "%s %s";
|
||||
static final String ORDER_BY_CLAUSE = " ORDER BY %s";
|
||||
public static final String REGEX_WILDCARD = ".*";
|
||||
|
||||
@@ -138,16 +138,21 @@ public class DelegatingGraphDatabase implements GraphDatabase {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends PropertyContainer> Index<T> createIndex(Class<T> type, String indexName, IndexType indexType) {
|
||||
IndexManager indexManager = delegate.index();
|
||||
if (isNode(type)) {
|
||||
if (indexManager.existsForNodes(indexName))
|
||||
return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forNodes(indexName));
|
||||
Index<Node> index = indexManager.forNodes(indexName, indexConfigFor(indexType));
|
||||
return (Index<T>) index;
|
||||
} else {
|
||||
if (indexManager.existsForRelationships(indexName))
|
||||
return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forRelationships(indexName));
|
||||
return (Index<T>) indexManager.forRelationships(indexName, indexConfigFor(indexType));
|
||||
Transaction tx = delegate.beginTx();
|
||||
try {
|
||||
IndexManager indexManager = delegate.index();
|
||||
if (isNode(type)) {
|
||||
if (indexManager.existsForNodes(indexName))
|
||||
return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forNodes(indexName));
|
||||
Index<Node> index = indexManager.forNodes(indexName, indexConfigFor(indexType));
|
||||
return (Index<T>) index;
|
||||
} else {
|
||||
if (indexManager.existsForRelationships(indexName))
|
||||
return (Index<T>) checkAndGetExistingIndex(indexName, indexType, indexManager.forRelationships(indexName));
|
||||
return (Index<T>) indexManager.forRelationships(indexName, indexConfigFor(indexType));
|
||||
}
|
||||
} finally {
|
||||
tx.success();tx.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.neo4j.support.index;
|
||||
|
||||
import org.neo4j.graphdb.PropertyContainer;
|
||||
import org.neo4j.graphdb.ResourceIterator;
|
||||
import org.neo4j.graphdb.index.IndexHits;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -46,7 +47,7 @@ public class EmptyIndexHits<S extends PropertyContainer> implements IndexHits<S>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<S> iterator() {
|
||||
public ResourceIterator<S> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.neo4j.support.typerepresentation;
|
||||
|
||||
import org.neo4j.graphdb.PropertyContainer;
|
||||
import org.neo4j.graphdb.Transaction;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.neo4j.graphdb.index.IndexHits;
|
||||
import org.neo4j.helpers.collection.ClosableIterable;
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.data.neo4j.support.typerepresentation;
|
||||
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.NotFoundException;
|
||||
import org.neo4j.graphdb.PropertyContainer;
|
||||
import org.neo4j.graphdb.Relationship;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.core.NodeTypeRepresentationStrategy;
|
||||
@@ -52,9 +49,14 @@ public class TypeRepresentationStrategyFactory {
|
||||
}
|
||||
|
||||
private static Strategy chooseStrategy(GraphDatabase graphDatabaseService) {
|
||||
if (isAlreadyIndexed(graphDatabaseService)) return Strategy.Indexed;
|
||||
if (isAlreadySubRef(graphDatabaseService)) return Strategy.SubRef;
|
||||
return Strategy.Indexed;
|
||||
Transaction tx = graphDatabaseService.beginTx();
|
||||
try {
|
||||
if (isAlreadyIndexed(graphDatabaseService)) return Strategy.Indexed;
|
||||
if (isAlreadySubRef(graphDatabaseService)) return Strategy.SubRef;
|
||||
return Strategy.Indexed;
|
||||
} finally {
|
||||
tx.success();tx.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAlreadyIndexed(GraphDatabase graphDatabaseService) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.neo4j.repository;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -54,6 +55,7 @@ import static org.neo4j.helpers.collection.MapUtil.map;
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/neo4j/repository/GraphRepositoryTests-context.xml"})
|
||||
@TestExecutionListeners({CleanContextCacheTestExecutionListener.class, DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
|
||||
@Transactional
|
||||
@Ignore
|
||||
public class CypherDslRepositoryTests {
|
||||
|
||||
@Autowired PersonRepository personRepository;
|
||||
|
||||
Reference in New Issue
Block a user