hibernate - Order second table before joining -
i have topicentity
contains many postentity
. each postentity
belongs 1 topicentity
. need sort topics last post creation date, creationdate
property of newest post in topic.
what think needs happen:
- get topics
- join posts belong topic
- sort posts creation date
- get newest post each topic , use date sort topics
this have currently:
this.session.createcriteria(topicentity.class, "topic") .createalias("topic.posts", "post", criteriaspecification.left_join) .addorder(order.asc("post.creationdate")).list();
this not sort topics in way. believe because not perform points 3 , 4 list.
anyway, hint me proper way of achieving desired result? prefer criteria, if hql required, that's fine.
Comments
Post a Comment