簡體   English   中英

將所有Node屬性分組並在Cypher中作為視圖返回

[英]Group toghether Node properties and return as a view in Cypher

我正在使用Neo4J和Spring Neo4j Data SDN 4的v2.2.3,我想使用密碼查詢返回節點的一些屬性並將其映射到POJO的屬性中。我在Spring數據存儲庫中的功能看起來像這樣

@Query(
"MATCH(n:ServiceProvider{profileStatus:{pStatus},currentResidenceState:{location}}) RETURN n.name,n.currentResidenceAddress ,n.employmentStatus,"
                       + "n.idProofType,n.idProofNumber 
ORDER BY n.registrationDate DESC SKIP{skip} LIMIT {limit}")
List<AdminSearchMapResult> getServiceProviderRecords(
       @Param("pStatus")String pStatus,
       @Param("location")String location,
       @Param("skip") int skip,@Param("limit")int limit);

我收到類似的錯誤

Scalar response queries must only return one column. Make sure your cypher query only returns one item.

我認為這是因為我無法將所有返回的屬性捆綁到可以映射到POJO的視圖中

如果我返回節點本身並將其映射到POJO中,它將起作用

請指導

可以使用@QueryResult完成

使用@QueryResult注釋AdminSearchMapResult POJO。 例如:

@QueryResult
public class AdminSearchMapResult {

  String name;
  String currentResidenceAddress;
...

}

如果別名與字段名稱不同,則可以選擇使用@Property(name = "n.idProofType")注釋屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM