-->
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.  [ 3 posts ] 
Author Message
 Post subject: configure automatic date in hibernate mapping files
PostPosted: Tue Aug 05, 2008 8:38 am 
Newbie

Joined: Tue Aug 05, 2008 8:33 am
Posts: 2
hi,

i want to insert a date in my oracle database but i want it to be automatic (ie when the object is saved in database the column "creation_date" is filled with the current date).

can we configure this in mapping files ? i have the same issue with the column "modification_date".

thank you !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 9:55 am 
Newbie

Joined: Thu Mar 27, 2008 11:45 am
Posts: 10
Location: Russia
As far as I know, You could not dot it using mapping files.
But you can use triggers or somethig else on DB side.
Also you can fill date prorties in constructor of you class.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 05, 2008 2:13 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
For the "modification_date" column it should be possible to use the <timestamp> mapping (see http://www.hibernate.org/hib_docs/v3/re ... -timestamp).

As a side effect this also enables versioning using optimistic locking, which may or may not be desired.

Another option is to implement an Interceptor. See http://www.hibernate.org/hib_docs/v3/re ... vents.html which contains an example that is more or less identical to your case.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.