0
votes

I have a column in my Database, called updateddate, which should get inserted with sysdate through application. If my application code encounters some exception, even then I want this column value to be inserted with sysdate through database. So, through SQL script, I have given this column default to sysdate.

Below is my hibernate hbm xml file,

<property name="updatedDate" type="timestamp">
    <column name="UPDATED_DATE" ></column>
</property>

However, the column is not getting inserted through my application when there are no exceptions. It is getting updated through DB. I am saying this by looking at the date format.

How to make the column to be inserted through application and only when it encounters exception it should get inserted through DB? I tried insert=true. But didn't help.

1
"I am saying this by looking at the date format." Could you elaborate more on this please? - Dragan Bozanovic
Date format in application code is dd-mm-yyyy without timestamp. Whereas date format inserted through DB is with timestamp. - user2488578

1 Answers

0
votes

I am not quite sure why you want to do this, but your application should set updatedDate to the current system date/time. The database default will only be applied if your application inserts a record with updatedDate = null.