Hi,
I have a large object graph in the database which a user may update by uploading a file. When the file is uploaded the data is parsed into objects. This object graph is then passed to hibernate and saved.
The problem is that the user may select to update their objects in the database with the file, so the parsed objects are transient, have PKs of 0, but those objects may reflect persistent objects.
In my equals() methods of those objects I have this, where id is PK -
Code:
if(this.id != 0 && that.id != 0)
.... then compare by id.....
....
....else compare by other values
However, hibernate does not find the reflected persistent object with the parsed transient one and I end up with two persistent objects with different PKs but the same values for the other fields.
Does hibernate just compare objects by PK?