gargrishi wrote:
Hi,
I am new to hibernate. I would like to know what is the best way to insert current date to one of my column in the table. This column should be updated to current date whenever there is a change in any value of row.
i tried handling in java code and made a getUpdateDate() method which returns "new Date()". But this has a problem. while i make a new row, it inserts other values and then make an update call to update current date as the value "new Date()" changes the state of object to some microseconds.
You should look at using a <timestamp> mapping for the date field and Hibernate will take care of updating it for you whenever it persists the data. It will also use this field for optimistic locking...