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:

  1. get topics
  2. join posts belong topic
  3. sort posts creation date
  4. 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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -