DATAGRAPH-232 Initially create the indexes used for the type-representation-strategy (__types__ and __rel_types__) so that generated cypher queries don't complain about missing indices on an empty database

This commit is contained in:
Michael Hunger
2012-05-08 13:01:05 +02:00
parent 8e62b3feef
commit 3bf64c80f5
3 changed files with 11 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ public abstract class AbstractIndexingTypeRepresentationStrategy<S extends Prope
this.indexProvider = indexProvider;
INDEX_NAME = indexName;
this.clazz = clazz;
getTypesIndex();
}
@SuppressWarnings("unchecked")

View File

@@ -28,6 +28,7 @@ import org.neo4j.test.ImpermanentGraphDatabase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.conversion.EndResult;
import org.springframework.data.neo4j.model.Person;
import org.springframework.test.context.CleanContextCacheTestExecutionListener;
import org.springframework.test.context.ContextConfiguration;
@@ -55,6 +56,12 @@ public class NoIndexDerivedFinderTest {
assertEquals(0,IteratorUtil.count(result));
}
@Test @Transactional
public void findAllInitiallyWithoutIndexCreation() {
EndResult<Person> result = personRepository.findByHeight( (short) 100 );
assertEquals(0,IteratorUtil.count( result ));
}
@Test @Transactional
public void findByName() {
Iterable<Person> result = personRepository.findByName("");

View File

@@ -23,6 +23,7 @@ import org.springframework.data.neo4j.annotation.MapResult;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.annotation.QueryType;
import org.springframework.data.neo4j.annotation.ResultColumn;
import org.springframework.data.neo4j.conversion.EndResult;
import org.springframework.data.neo4j.model.Group;
import org.springframework.data.neo4j.model.Person;
import org.springframework.data.repository.query.Param;
@@ -84,6 +85,8 @@ public interface PersonRepository extends GraphRepository<Person>, NamedIndexRep
@Query("start person=node:`name-index`('name:*') return person.name as name, person order by name asc ")
Iterable<NameAndPersonResult> getAllNamesAndPeople();
EndResult<Person> findByHeight( short height );
@MapResult
interface NameAndPersonResult
{