我在Java中使用Hibernate。MyEclipse + Hibernate不按ID排序属性集?
我有两个表与外键相关联。
Table: country Fields: ID, Name POJO class name : Country POJO class properties: id, name, cities Table: city Fields: ID, Name, CountryID POJO class name : Country
然后我用MyEclipse的“hibernate reverse engineering”。它自动创建DAO,摘要和pojo类。
一切工作得很好。当我请求一个Country对象时,Hibernate检索它,并填写CountryID为country.id的城市。
还是一切正常,但当我列出的“城市”属性(java的设置类型),然后打印出我得到这个无序列表中的所有城市的标识:
ID: 5 ID: 1 ID: 4 ID: 2
我应该在哪里编辑得到城市的有序我从CountryDAO类获取国家实例时的ID?
安迪,谢谢你的考虑;但我仍然得到例外。你能检查一下有什么问题吗? http://pastebin.ca/1410416 – 2009-05-02 16:03:09