Last active
February 15, 2016 22:59
-
-
Save Leward/f2804d64d66f25438f19 to your computer and use it in GitHub Desktop.
@QueryResult
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
public interface IdeaRepository extends GraphRepository<Idea> { | |
@Query("MATCH (i:Idea) WHERE id(i) = {0} WITH i " + | |
"OPTIONAL MATCH (u:User)-[:UPVOTE]->(i) " + | |
"WITH i, collect(u) as upVoters " + | |
"OPTIONAL MATCH (u:User)-[:DOWNVOTE]->(i) " + | |
"RETURN id(i) as ideaId, upVoters, collect(u) as downVoters ") | |
Iterable<IdeaVotesQueryResult> findVoters(Long id); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IdeaVotesQueryResult { | |
private Long ideaId; | |
private Set<User> upVoters; | |
private Set<User> downVoters; | |
public Long getIdeaId() { | |
return ideaId; | |
} | |
public void setIdeaId(Long ideaId) { | |
this.ideaId = ideaId; | |
} | |
public Set<User> getUpVoters() { | |
return upVoters; | |
} | |
public void setUpVoters(Set<User> upVoters) { | |
this.upVoters = upVoters; | |
} | |
public Set<User> getDownVoters() { | |
return downVoters; | |
} | |
public void setDownVoters(Set<User> downVoters) { | |
this.downVoters = downVoters; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment