tenwit wrote:
My approach for this sort of field depends on whether or not the field has to be updated on every write.
If the field is set once and only once, on initial row creation, then map the field with insert="false" update="false", and set the DB default value for the column to be the system date (that's getdate() for SQLServer, though that varies by DBMS).
If the field has to be updated every time the row is modified, then use the hibernate <timestemp> element. See refdocs, section 5.1.8.
Thanks for your help I have one more question
I got it to working for one time insert by using the following code
<property name="createDate" column="createDate" type="java.util.Date" update="false" insert="false"/>
to insert every time a record is modified didnt work
<timestamp column="LastModDt" name="lastModDate" type="timestamp" />
and defined lastmoddate property as date property in the object
I am getting the following erro:
org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "timestamp".
Can you please help me