hibernate注解排序@orderBy

[html]  view plain  copy
  1. @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "province")  
  2. @OrderBy(clause = "cityId asc")  
  3. public Set<City> getCities() {  
  4.     return this.cities;  
  5. }  
  6.   
  7. public void setCities(Set<City> cities) {  
  8.     this.cities = cities;  
  9. }  





如果你也遇到,OneToMany从数据库取出来的集合是混乱的,那就加上@OrderBy 吧!!


你可能感兴趣的:(异常记录)