0
我有以下資料庫我Domain
類:彈簧數據的Neo4j + @Query拋出PropertyReferenceException
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);
}
從GraphManager
我打電話attachLabel
如下(一個服務,這是使用IDomainRepository):
@Transactional
public void attachLabel(Domain domain, String label){
domainRepository.attachLabel(domain.getId(), label);
}
這裏是我的測試情況下,attachLabel
方法:
@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());
}
我出現以下情況例外,當我在加載的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)
似乎SDN是某種試圖映射到Domain
類的屬性attachLabel
(附後)第一部分。我試着重命名該方法,但仍然顯示錯誤。
配置:Sprind-Data-Neo4j版本3.1.1.RELEASE,neo4j版本2.1.2。
修復 問題是,我不小心使用了從mongodb命名空間的@Query註釋而不是od neo4j。
是的,我注意到了,並且已經按照您的建議解決了它。我還注意到有用於管理標籤的@Labels註解(計劃)。什麼時候會得到支持? – mayr