diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java index ac67b3d84..9fbdf3264 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/Neo4jConfiguration.java @@ -203,8 +203,6 @@ public abstract class Neo4jConfiguration { mappingContext.setInitialEntitySet(initialEntitySet); } mappingContext.setEntityAlias(entityAlias()); - mappingContext.setIsLabelBased(nodeTypeRepresentationStrategy().isLabelBased()); - mappingContext.setFailWhenIncompatibleLabelIndexUsage(false); return mappingContext; } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/MappingInfrastructureFactoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/MappingInfrastructureFactoryBean.java index 58ebd27db..c53066fa8 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/MappingInfrastructureFactoryBean.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/MappingInfrastructureFactoryBean.java @@ -104,7 +104,6 @@ public class MappingInfrastructureFactoryBean implements FactoryBean referenceAnnotations = new IdentityHashMap(); protected Neo4jPersistentEntityImpl createPersistentEntity(TypeInformation typeInformation) { @@ -90,29 +67,9 @@ public class Neo4jMappingContext extends AbstractMappingContext entity = super.addPersistentEntity(typeInformation); Collection> superTypeEntities = addSuperTypes(entity); entity.updateStoredType(new StoredEntityType(entity,superTypeEntities,entityAlias)); - doAdditionalEntityVerification(entity); return entity; } - private void doAdditionalEntityVerification(Neo4jPersistentEntityImpl entity) { - // NW-HACK checking if null for isLabelBasedTRSInUse, but should - // prob just blow up?? - if (isLabelBasedTRSInUse!= null && !isLabelBasedTRSInUse) { - entity.doWithProperties(new PropertyHandler() { - @Override - public void doWithPersistentProperty(Neo4jPersistentProperty persistentProperty) { - if (persistentProperty.isIndexed() && persistentProperty.getIndexInfo().isLabelBased()) { - if (failWhenIncompatibleLabelIndexUsage) { - throw new RuntimeException(format("Incompatible entity definition: property %s has label based index annotation however label type representation strategy not in use",persistentProperty.getName())); - } else { - log.warn("Incompatible entity definition: property {} has label based index annotation however label type representation strategy not in use - will be treated as normal property", persistentProperty.getName()); - } - } - } - }); - } - } - private List> addSuperTypes(Neo4jPersistentEntity entity) { List> entities=new ArrayList>(); final Class type = entity.getType(); diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/AbstractDerivedFinderMethodTestBase.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/AbstractDerivedFinderMethodTestBase.java index 78d799e21..c9d9135c5 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/AbstractDerivedFinderMethodTestBase.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/AbstractDerivedFinderMethodTestBase.java @@ -156,7 +156,7 @@ public abstract class AbstractDerivedFinderMethodTestBase { } @Test - public void testLabelBasedIndexQueryWithOneParam() throws Exception { + public void testSchemaIndexQueryWithOneParam() throws Exception { assertRepositoryQueryMethod(ThingRepository.class, "findByAlias", new Object[]{"foo"}, diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForIndexedBasedTRSTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForIndexedBasedTRSTests.java index 7ec4072bb..9490da81f 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForIndexedBasedTRSTests.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForIndexedBasedTRSTests.java @@ -18,7 +18,6 @@ package org.springframework.data.neo4j.repository.query; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.neo4j.index.lucene.ValueContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.neo4j.core.NodeTypeRepresentationStrategy; import org.springframework.data.neo4j.support.typerepresentation.IndexBasedNodeTypeRepresentationStrategy; @@ -30,10 +29,6 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; @@ -96,25 +91,17 @@ public class DerivedFinderMethodForIndexedBasedTRSTests extends AbstractDerivedF @Test @Override - public void testLabelBasedIndexQueryWithOneParam() throws Exception { - - // Ensure mappingContext set NOT to fail (but rather warn) - // when incompatibility detected - assertFalse(ctx.isFailWhenIncompatibleLabelIndexUsage()); + public void testSchemaIndexQueryWithOneParam() throws Exception { /* - Is this the correct logic??? - what should we do when a derived - field has been marked as a label based indexed field and - we have a legacy based indexing strategy in play. Have currently - added in properties failWhenIncompatibleLabelIndexUsage and - isLabelBasedTRSInUse to Neo4jMappingContext to help - + TODO - Determine exactly what correct query should be when + using a schema based index and a Legacy based TRS */ // "findByAlias", this.trsSpecificExpectedQuery = DEFAULT_START_CLAUSE + " WHERE `thing`.`alias` = {0} RETURN `thing`"; this.trsSpecificExpectedParams = new Object[] { "foo" }; - super.testLabelBasedIndexQueryWithOneParam(); + super.testSchemaIndexQueryWithOneParam(); } @Test diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForLabelBasedTRSTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForLabelBasedTRSTests.java index 29275b94b..33bab439e 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForLabelBasedTRSTests.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/DerivedFinderMethodForLabelBasedTRSTests.java @@ -28,8 +28,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; -import java.util.Date; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.fail; @@ -370,12 +368,12 @@ public class DerivedFinderMethodForLabelBasedTRSTests extends AbstractDerivedFin @Test @Override - public void testLabelBasedIndexQueryWithOneParam() throws Exception { + public void testSchemaIndexQueryWithOneParam() throws Exception { // findByAlias this.trsSpecificExpectedQuery = DEFAULT_MATCH_CLAUSE + " WHERE `thing`.`alias` = {0}" + " RETURN `thing`"; this.trsSpecificExpectedParams = new Object[] { "foo" }; - super.testLabelBasedIndexQueryWithOneParam(); + super.testSchemaIndexQueryWithOneParam(); } }