아래 Cypher 쿼리가 있습니다. 플레이어 목록과 각 플레이어가 수행 한 모든 리그 목록을 반환합니다. 이제 각 반환 된 플레이어에 대해 NodeProxy
대신 Person
NodeEntity
을 만들고 싶습니다. 이렇게하는 효율적인 방법이 무엇인지 궁금합니다.spring-data-neo4j에서 NodeProxy를 NodeEntity로 변환하십시오.
String q = "START t=node({teamId}) MATCH player-[:PLAYED_WITH_TEAM]->t-[:CONTESTED_IN]->league WITH player AS player, league.startDate AS startDate, league.name AS leagueName ORDER BY startDate RETURN player, collect(leagueName) AS leagueNames";
Map<String, Object> params = Maps.newHashMap();
params.put("teamId", selectedTeam);
Result<Map<String, Object>> result = template.query(q, params);
final List<Player> players = new ArrayList<Player>();
result.handle(new Handler<Map<String, Object>>()
{
@Override
public void handle(Map<String, Object> value)
{
players.add((Player) value.get("player"));
}
});
예외
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/avl] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: org.neo4j.kernel.impl.core.NodeProxy cannot be cast to com.aravind.avl.domain.Player] with root cause
java.lang.ClassCastException: org.neo4j.kernel.impl.core.NodeProxy cannot be cast to com.aravind.avl.domain.Player
at com.aravind.avl.controller.RegistrationController$1.handle(RegistrationController.java:103)
트랜잭션 컨텍스트에 있습니까? – tstorms