Reputation: 149
I'm using Spring Data Neo4j 3.0.0 in my web site.
I have some problem doing develope. I use @Query Annontation in @NodeEntity model class.
@Query(value = "START a=node({self}) MATCH (a)<-[:`COMMENT_TO`]-(b) RETURN b ORDER BY b.createdAt DESC")
private Set<BaseComment> sortedComments;
and I try to use this result...then sortedComments type was SpringEndResult. How can i use this result to Set ?
and can I use this in .jsp? when I using sortedComments in jsp with JSTL(c:foreach). I met SpringEndResult doesn't have property exception.
I'm not english native. Thanks for your response. :)
@Test
public void getList() {
List<SimpleArticle> articles = articleService.getAll(0, 10).getContent();
for (SimpleArticle simpleArticle : articles) {
Set<BaseComment> comments = simpleArticle.getSortedComments();
for (BaseComment baseComment : comments) {
log.info(baseComment);
}
}
}
And I met
java.lang.ClassCastException: org.springframework.data.neo4j.rest.SpringEndResult cannot be cast to kr.carcare.model.bbs.BaseComment
This is my domain class
public class SimpleArticle extends BaseArticle {
@RelatedTo(type = "COMMENT_TO", direction = Direction.INCOMING)
@Fetch
private Set<BaseComment> comments;
@Query("START a=node({self}) MATCH (a)<-[:`COMMENT_TO`]-(b) RETURN b ORDER BY b.createdAt DESC")
private Set<BaseComment> sortedComments;
Upvotes: 0
Views: 64
Reputation: 1462
Try using SpringEndResult's "as" method and feed it something like Set.class (or something similar that implements Iterable).
I can't recall if that's the exact syntax, but, the "as" method takes a class parameter that extends Iterable, where R is the template type; in your case, R is BaseComment.
Upvotes: 1