1つのエンティティと1つのリレーションシップクラスを持つNeo4jデータベースを使用して、ビーコンが互いに隣接するビーコンネットワークを設計しています。2つのビーコン間の関係を取得する必要がありますが、その方法がわかりません。これが2つのクラスです
ビーコンクラス
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
}
隣接関係クラス
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
}
リポジトリを作成して取得しようとしましたが、クエリはNeo4jブラウザで機能しますが、ここではデータを取得せず、括弧だけを取得します。
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();
}
どんな助けでも大歓迎です。
あなたはする必要がありますreturn *
、またはreturn a, b, c
そうOGMは、あなたのオブジェクトモデルへのクエリ応答をマッピングするために必要なすべての詳細を推測することができます。
クエリがNeo4jブラウザで機能した理由は、クエリが自動的に変更されて隣接するパス(この場合はビーコンオブジェクト)が展開されるためです。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加