-->
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: conditional update of column depeding upon save/update
PostPosted: Tue Oct 16, 2012 2:57 am 
Newbie

Joined: Tue Oct 16, 2012 2:46 am
Posts: 1
I have 2 columns in a table ,ADD_DATE and UPDATE_DATE.
While doing saveOrUpdate(hibernate),if it is the first time it should populate the ADD_DATE and next update onwards
it should populate UPDATE_DATE.
How could it be done without querying the database(i.e in hibernate Mapping level)??


Last edited by suryanarayan on Tue Oct 16, 2012 3:51 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: conditional update of column depeding upon save/update
PostPosted: Tue Oct 16, 2012 3:47 am 
Beginner
Beginner

Joined: Fri Jul 20, 2007 10:38 am
Posts: 49
Here's one option:
- create a constructor that sets the Date addDate to the date/time you want
- in your saveOrUpdate method of your dao, set the updateDate with the date/time you want.
OR
- in your saveOrUpdate method of your dao, check if the addDate is set and if not set it otherwise set the updateDate.


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.