OK, I added the <datagraph:repositories .../> config you suggested and defined my PersonRepository as you suggested:
NOTE: I wasn't able to extend NodeGraphRepository, since PersonRepository is an interface.
Code:
@Repository
public interface PersonRepository extends GraphRepository<Person>,
NamedIndexRepository<Person>
{}
I then re-ran my tests, and the test that searches by person id was now failing:
Code:
@Test
@Transactional
public void testGetById()
{
Person p = new Person("1", "John Smith");
Person person = personRepository.findByPropertyValue("principal_id_index", "id", "1");
assertThat(person, CoreMatchers.equalTo(p));
logger.info(person);
}
Code:
Apr 20, 2011 7:19:12 AM org.springframework.test.context.TestContextManager retrieveTestExecutionListeners
INFO: @TestExecutionListeners is not present for class [class org.mycompany.graph.person.PersonDaoTests]: using defaults.
Apr 20, 2011 7:19:12 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@743399: startup date [Wed Apr 20 07:19:12 EDT 2011]; root of context hierarchy
Apr 20, 2011 7:19:12 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/spring/graphRepository-config.xml]
Apr 20, 2011 7:19:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@18fb1f7: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,appConfig,org.mycompany.graph.config.AppFeatures#0,org.springframework.data.graph.neo4j.config.Neo4jConfiguration#0,graphDatabaseContext,conversionService,graphRelationshipInstantiator,graphEntityInstantiator,directGraphRepositoryFactory,neo4jRelationshipBacking,relationshipEntityStateFactory,neo4jNodeBacking,nodeEntityStateFactory,transactionManager,configurationCheck,persistenceExceptionTranslator,org.mycompany.graph.config.DatabaseConfig#0,dataSource,graphDatabaseService,personRepository,org.springframework.data.repository.support.RepositoryInterfaceAwareBeanPostProcessor#0,appFeatures,databaseConfig,noteDao]; root of factory hierarchy
Apr 20, 2011 7:19:13 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA UserTransaction: org.neo4j.kernel.impl.transaction.UserTransactionImpl@1e78c96
Apr 20, 2011 7:19:13 AM org.springframework.transaction.jta.JtaTransactionManager checkUserTransactionAndTransactionManager
INFO: Using JTA TransactionManager: org.neo4j.kernel.impl.transaction.SpringTransactionManager@bf053f
Apr 20, 2011 7:19:13 AM org.springframework.test.context.transaction.TransactionalTestExecutionListener startNewTransaction
INFO: Began transaction (1): transaction manager [org.springframework.transaction.jta.JtaTransactionManager@120540c]; rollback [true]
Apr 20, 2011 7:19:13 AM org.springframework.data.graph.neo4j.fieldaccess.DelegatingFieldAccessorFactory factoryForField
INFO: Factory org.springframework.data.graph.neo4j.fieldaccess.OneToNRelationshipFieldAccessorFactory@3a9d95 used for field: private java.util.Set org.mycompany.graph.model.Person.aliases
Apr 20, 2011 7:19:13 AM org.springframework.data.graph.neo4j.fieldaccess.DelegatingFieldAccessorFactory factoryForField
INFO: Factory org.springframework.data.graph.neo4j.fieldaccess.PropertyFieldAccessorFactory@e99ce5 used for field: private java.lang.String org.mycompany.graph.model.acl.PrincipalImpl.id
Apr 20, 2011 7:19:13 AM org.springframework.data.graph.neo4j.fieldaccess.DelegatingFieldAccessorFactory factoryForField
INFO: Factory org.springframework.data.graph.neo4j.fieldaccess.PropertyFieldAccessorFactory@e99ce5 used for field: private java.lang.String org.mycompany.graph.model.acl.PrincipalImpl.name
Apr 20, 2011 7:19:13 AM org.springframework.test.context.transaction.TransactionalTestExecutionListener endTransaction
INFO: Rolled back transaction after test execution for test context [[TestContext@1b32627 testClass = PersonDaoTests, locations = array<String>['org.mycompany.graph.config.AppConfig'], testInstance = org.mycompany.graph.person.PersonDaoTests@8dcd5d, testMethod = testGetById@PersonDaoTests, testException = java.lang.AssertionError:
Expected: <Person [aliases=null, PrincipalImpl [id=1, name=John Smith]]>
got: null
]]
Here's my Person model again:
Code:
@NodeEntity
public class Person extends PrincipalImpl
{
@RelatedTo(type = "alias", elementClass = Person.class)
private Set<Person> aliases;
}
@NodeEntity
public abstract class PrincipalImpl implements Principal
{
@Indexed(indexName = "principal_id_index")
private String id;
@Indexed(indexName = "principal_name_index")
private String name;
}