I've got a strange problem.. I'm using Hibernate to load some objects (Table objects) from my database, the list that is generated is given to a JComboBox for the user to select one. A table is unique by its row_id. So the equals method of the Table object only looks at the row_id.
When the data is loaded into the ComboBox, the user can't select another object (always returns to the first one). Turned out this was because of the Table that was passed to the equals method always had a row_id of null.
Perhaps some code:
Loading the objects from the database and adding it to the box (this is ofcourse a simplified version):
The equals method of the Table object:
It's here to the table.row_id is null when Swing is checking the objects in the JComboBox..
If I try this the result is the same:
I get false, and the row_id of the list.get(2) is still null (changing the object that is passed to another table (like list.get(4)) doesn't change anything.. Manually creating Table objects works just fine..
What is Hibernate doing to my objects?
Joined: Mar 12, 2004
changing the table.row_id in the equals method to table.getRow_id() fixed the problem..