I am doing a saveOrUpdate but the problem I’m facing is that it is overwriting the old data which is already in the table.
I have a table in which there is a correlationID as key and against that id i’m persisting some data first, then again against the same id passing an acknowledgement message in another column of the same table later. But this overwrites the old data I have in the table and what I get is an empty table with the id & message, the other columns are nullified.
I am using Hibernate Mapping Files (.hbm.xml)
Suggestions on how to keep the old data and just update the one column only ?
Update:
I am getting this when trying to load persistence instance:
SEVERE: IllegalArgumentException in class: common.entity.AbstractDetailsKey, getter method of property: correlationId
...
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of common.entity.AbstractDetailsKey.correlationId
...
Caused by: java.lang.IllegalArgumentException: 666
Are you loading the entity first, before updating and saving? Or are you just creating an entity instance, slapping the id you want in there, and changing one property on the empty instance? That would be bad, because you just told your ORM that the entity with id X now only has one property with a value, so of course it’s going to null out all the other column’s values.
Sounds like you need to either
1) Load the row, then make the modification, then saveOrUpdate
2) Use hql to update just the one column.