java - How to have a sorted set of objects based on a specific field? -
i need retrieve sorted list of objects based on sort field
; collection type sortedset
code throws following exception. tried add @sort
annotation explained in sorted collection section of hibernate documentation seems deprecated!
exception
caused by: org.hibernate.annotationexception: sorted collection must define , ordering or sorting
code
sortedset<offer> offers = new treeset<offer>();
classes
public class person { @id long id; @onetomany //@orderby("sort asc") <<< if use 1 offer in collection sortedset<offer> offers = new treeset<offer>(); ... } public class offer implements comparable<offer>{ @id long id; string name; short sort; @override public int compareto(offer o) { return sort - o.sort; } }
you need specify column name put in order clause
try add annotation sortedset
@javax.persistence.orderby("sort")
Comments
Post a Comment