Spring Data Neo4j 4 (SDN4) を使用しています。,@QueryResult を使用して複数のエンティティを返そうとしています
例外はスローされませんが、@QueryResult オブジェクトではすべてが null モデルは (:User)-[:ROLE]-(:Role) のように単純です
根本的な原因を知っている人はいますか?
ユーザーモデル
@NodeEntity
public class User implements UserDetails {
@GraphId
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private String userId;
@Relationship(type="ROLE")
private Set<Role> roles = new HashSet<>();
public ADUser getaDUser() {
return aDUser;
}
public void setaDUser(ADUser aDUser) {
this.aDUser = aDUser;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
}
ロールモデル
@NodeEntity
public class Role implements java.io.Serializable {
@GraphId Long id;
private String name;
public Role(){}
public Role(String name){
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
クエリ結果
@QueryResult
public class UserPermission {
private User user;
private List<Role> roles;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
ユーザーリポジトリ
public interface UserRepository extends GraphRepository<User>{
public User findByUserId(String userId);
@Query(" Match (u:User)-[:ROLE]->(r) return u as user , collect(r) as roles ")
public UserPermission findUserWithRoles();
}
そしてログは
2015-08-05 17:56:18 INFO Neo4jSession:461 - --------- new request ----------
2015-08-05 17:56:18 INFO Neo4jSession:461 - getOrCreateTransaction() being called on thread: 1
2015-08-05 17:56:18 INFO Neo4jSession:461 - Session identity: org.neo4j.ogm.session.delegates.TransactionsDelegate@1dcfae07
2015-08-05 17:56:18 INFO Neo4jSession:461 - There is no existing transaction, creating a transient one
2015-08-05 17:56:18 INFO DefaultRequest:57 - POST http://localhost:7474/db/data/transaction/commit, request: {"statements":[{"statement":"Match (u:User)-[:ROLE]->(r) return u as user , collect(r) as roles","parameters":{},"resultDataContents":["row"],"includeStats":false}]}
2015-08-05 17:56:18 INFO DefaultRequest:86 - Response is OK, creating response handler
2015-08-05 17:56:18 WARN SingleUseEntityMapper:97 - Unable to find property: roles on class: model.UserPermission for writing
2015-08-05 17:56:18 WARN SingleUseEntityMapper:97 - Unable to find property: user on class: model.UserPermission for writing
2015-08-05 17:56:18 INFO JsonResponse:103 - Closing HttpResponse