-->
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.  [ 1 post ] 
Author Message
 Post subject: How to save the DB timestamp in column using Hibernate?
PostPosted: Thu Oct 07, 2010 3:35 am 
Newbie

Joined: Thu Oct 07, 2010 3:20 am
Posts: 1
Hi,

I want to save the DB timestamp value in one of the table column based on some business logic. Is there any option in hibernate to get the DB timestamp & set that value into EO while saving?

I have found following options but those will not helps in my scenario, I want to know if other alternatives are available.


1) Create an Oracle trigger which will invoke base on before insert/update/delete for each row of Deal history Table. In the Update clause, we need to check based on step status code and update the timestamp accordingly. (This should be the straight cut through way without even need to make modification to the current code as oracle trigger will override the value upon trigger happened).
Cons-- Some business logic not able to implement in trigger.

2) Hibernate formula and checks attributes for column mapping can be used as well (but I need to try this out, haven’t play with this piece before J)… need to do a formula as something like this…..
<formula>
case
when step_status_code = ‘02’ then 'update maker_timestamp'
else ''
end
</formula>
Cons--- approach is not do-able for update cycles… only insert cycles are permitted for auto-defaulting

3) Do a select of sysdate before any insert/update of deal history in the code.

Cons--We have few places in the code which we are doing the saving and bad thing is for batch process, we can’t escape on having multiple fetch of sysdate when we are going to insert for each records


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

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.