@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
@OrderBy("createDate asc")
public Set<Topic> getTopicSet() {
return topicSet;
}
@ManyToMany(fetch = FetchType.LAZY)
@Cascade(value = org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@Fetch(FetchMode.SELECT)
@JoinTable(name = "sem_R_role_authority", joinColumns = { @JoinColumn(name = "sem_role_id") }, inverseJoinColumns = { @JoinColumn(name = "sem_authority_id") })
@OrderBy("moudle asc")//给Set<Authority>集合按照Authority.moudle 排序
public java.util.Set<Authority> getAuthories() {
return authories;
}
-----------------------------------------
//给集合List<Moudle>排序,按照集合List<Moudle>中对象Moudle的属性sort排序,compare(Moudle o1, Moudle o2)的参数位置不一样,排序方式不一样,正序(o1,o2),倒序(o2,o1).
java.util.Collections.sort(parentlist, new Comparator<Moudle>(){
@Override
public int compare(Moudle o1, Moudle o2) {
if(o1.getSort()< o2.getSort()){
return -1;
}else if(o1.getSort() > o2.getSort()){
return 1;
}else{
return 0;
}
}
});