我正在設(shè)計(jì)一個(gè)信標(biāo)網(wǎng)絡(luò),其中信標(biāo)彼此相鄰,使用 Neo4j 數(shù)據(jù)庫(kù),其中它具有一個(gè)實(shí)體和一個(gè)關(guān)系類(lèi)。我需要檢索兩個(gè)信標(biāo)之間的關(guān)系,但無(wú)法弄清楚如何。這是兩個(gè)類(lèi)燈塔類(lèi)public class Beacon { @Id private String MAC; private String description; private String location; @Relationship(type = "ADJACENT") private List<Adjacent> adjacentList = new ArrayList<>(); public Beacon() { } public Beacon(String MAC, String description, String location) { this.MAC = MAC; this.description = description; this.location = location; } public void addAdjacency(Adjacent adjacent){ if (this.adjacentList==null){ this.adjacentList=new ArrayList<>(); } this.adjacentList.add(adjacent); }//Getters and Setters are excluded}相鄰關(guān)系類(lèi)public class Adjacent { @Id @GeneratedValue private Long id; private int angle; private int cost; @StartNode private Beacon startBeacon; @EndNode private Beacon endBeacon; public Adjacent() { } public Adjacent(int angle, int cost, Beacon startBeacon, Beacon endBeacon) { this.angle = angle; this.cost = cost; this.startBeacon = startBeacon; this.endBeacon = endBeacon; }//Getters and Setters are excluded}我已經(jīng)嘗試創(chuàng)建一個(gè)存儲(chǔ)庫(kù)并進(jìn)行檢索,但即使查詢?cè)?Neo4j 瀏覽器中有效,它也不會(huì)在此處檢索任何數(shù)據(jù),只是空白括號(hào)。public interface AdjacentRepository extends Neo4jRepository<Adjacent,Long> {@Query("match (b:Beacon{MAC:\"f:f:f:f\"})-[a:ADJACENT]-(c:Beacon{MAC:\"r:r:r:r\") return a") Adjacent findaRelationshipp();}任何幫助是極大的贊賞。
1 回答

犯罪嫌疑人X
TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
您需要return *
,否則return a, b, c
OGM 可以推斷出將查詢響應(yīng)映射到您的對(duì)象模型所需的所有詳細(xì)信息。
查詢?cè)?Neo4j 瀏覽器中起作用的原因是因?yàn)樗鼤?huì)自動(dòng)修改您的查詢以擴(kuò)展相鄰路徑,在本例中為 Beacon 對(duì)象。
添加回答
舉報(bào)
0/150
提交
取消