-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: automatically populate modified_date and creation_date
PostPosted: Wed Mar 15, 2006 12:33 am 
Newbie

Joined: Wed Mar 08, 2006 12:03 am
Posts: 4
I've got a table with two columns I would like to be populated automatically via Hibernate:

- modified_date
- creation_date

It probably goes without saying that I'd like to have the creation_date populated automatically only when the row is first inserted, and modified_date to be populated automatically every time the row is modified.

Additionally, I would like the date to come from the db itself, not the VM

From my reading, I think the creation_date one is impossible. Am I correct?

For the modified_date, I thought this line would work:

Code:
<timestamp name="modifiedDate" column="modifed_date" source="db" generated="always"/>    


But it doesn't seem to work. My modified_date column is still null after I insert a record. Anyone know what I'm doing wrong? Got an example hbm.xml file that would point me in the right direction? Thanks.

-j


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 8:09 am 
Newbie

Joined: Tue Mar 06, 2007 7:51 am
Posts: 2
I've got the same problem using HSQLDB.
I'm seeing the following queries:

Hibernate: insert into Measure (version, name, region, institution, startDate, endDate, creationTime, id) values (?, ?, ?, ?, ?, ?, ?, null)
Hibernate: call identity()
Hibernate: select measure_.lastModificationTime as lastModi9_2_ from Measure measure_ where measure_.id=?


But the lastModificationTime stays null...

anyone?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.