hibernate中集合排序
TreeSet
首先创建一个类实现Comparator接口,然后重写compare方法。如:
public int compare(Object o1, Object o2) {if (o1 instanceof Street && o2 instanceof Street) {Integer s1 = ((Street)o1).getId();Integer s2 = ((Street)o2).getId();return s1.intValue()-s2.intValue();}return 0;}