我是 java 新手。我想将 result 的值包装在简单的 java 类中。
Iterator<Map<String,Object>> result=template.query(cypher,params);
任何帮助将不胜感激。
我是 java 新手。我想将 result 的值包装在简单的 java 类中。
Iterator<Map<String,Object>> result=template.query(cypher,params);
任何帮助将不胜感激。
If you're using the template.query then you can either have it mapped to a domain entity or to the Map (and then you build the POJO yourself).
Otherwise, you can use a @Query
in a repository and map it to a query result class.
For example
@Query("MATCH (user:User) WHERE user.gender={0} RETURN user.name AS UserName, user.gender AS UserGender, user.account as UserAccount, user.deposits as UserDeposits")
Iterable<RichUserQueryResult> findUsersByGender(Gender gender);
@QueryResult
public class RichUserQueryResult {
private Gender userGender;
private String userName;
private BigInteger userAccount;
private BigDecimal[] userDeposits;
public Gender getUserGender() {
return userGender;
}
public String getUserName() {
return userName;
}
public BigInteger getUserAccount() {
return userAccount;
}
public BigDecimal[] getUserDeposits() {
return userDeposits;
}
}