2014-12-20 73 views
0

我想在Neo4j中堅持一段關係,但不起作用。查看我的查詢。我的域對象與它自己有這種關係。保存neo4j中的關係

@RelatedTo (type="PLUS_ME", direction = Direction.BOTH) 
private Set<Errand> plusMe; 

然後我用GraphRepository運行這個查詢。

Errand e = new Errand(); 
    Errand e1 = new Errand(); 
    e = template.save(e); 
    e1 = template.save(e1); 
    p (e.getId() + " " + e1.getId()); 
    String query = "MATCH (one:Errand)" + 
       "WHERE one.id = " + e.getId() + 
       "MATCH (two:Errand)" + 
       "WHERE two.id = " + e1.getId() + 
       "CREATE (one)-[b:PLUS_ME]->(two)" + 
       "CREATE (two)-[a:PLUS_ME]->(one)"; 
    eRepo.query(query, null); 

但是當我用junit運行這個查詢時,我得到0作爲大小。

eRepo.findByPlusMe(e).size(); 

回答

0
  1. 使用參數
  2. 你不需要的反比關係
  3. 。您確定要匹配語句返回正確的差事?
  4. 你能展示你的Errand課程的結構嗎?
  5. 是您的findByPlusMe存儲庫查詢帶註釋或派生的查詢嗎?