I have following repository for my Domain
class:
public interface IDomainRepository extends GraphRepository<Domain>, RelationshipOperationsRepository<Domain>{
//cause of error
@Query("MATCH n WHERE id(n) = {0} SET n :{1}")
public void attachLabel(Long id, String label);
}
From GraphManager
(a service, which is using IDomainRepository) i'm calling attachLabel
as following:
@Transactional
public void attachLabel(Domain domain, String label){
domainRepository.attachLabel(domain.getId(), label);
}
And here is my test case, for attachLabel
method:
@Test
public void attachLabelSuccess(){
Domain domain = new Domain();
domain.setName(UUID.randomUUID().toString());
domain.setDescription("xyz");
domain = graphManager.create(domain);
graphManager.attachLabel(domain, "DummyLabel");
Domain d1 = domainRepository.findOne(domain.getId());
//Should have [Domain, DummyLabel]
Assert.assertEquals(2, d1.getLabels().size());
}
I get the following exception, when I run the test it fails at loading ApplicationContext:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'IDomainRepository':
Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException:
No property attach found for type Domain!
...
Caused by: org.springframework.data.mapping.PropertyReferenceException:
No property attach found for type Domain!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:359)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)
Seems that SDN is somehow trying to map first part of attachLabel
(attach) to property of Domain
class. I've tried to rename the method, but the error still appears.
Configuration: Sprind-Data-Neo4j version 3.1.1.RELEASE, neo4j version 2.1.2.
FIXED The problem was, that I accidentally used @Query annotation from mongodb namespace instead od neo4j.