I use Hibernate with Java.
I have two tables which are associated with foreign keys.
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
Then I use "hibernate reverse engineering" of MyEclipse. It creates DAOs, abstracts and pojo classes automatically.
Everything works very well. When I request a Country object, Hibernate retrieves it and fills the property "cities" with cities which has CountryID as country.id.
Still everything fine but when I list "cities" property (java Set type), then print out IDs of all cities I got this unordered list:
ID: 5 ID: 1 ID: 4 ID: 2
Where should I edit to get cities ordered by ID when I obtain Country instances from the CountryDAO class?