-->
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: how to insert sysdate to DATE column?
PostPosted: Tue Jul 27, 2004 12:42 pm 
Newbie

Joined: Tue Jul 27, 2004 11:27 am
Posts: 1
Location: NYC
Given an Oracle table FOO mapped to object Foo, and a DATE NOT NULL column FOO.T_CREATE that is mapped to Foo.TCreate, how can I get Hibernate to initialize this column using SYSDATE?

I.e., if I create a new Foo object, and call session.insert() without setting the Foo.TCreate property, Hibernate's INSERT query should use SYSDATE as a default for the T_CREATE column. So I want the timestamp to be initialized from the database, not Java.

How can I do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 2:13 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
For CreateTimestamp the easiest way to do it is to have a DEFAULT of SYSDATE in your table creation script. For the UpdateTimestamp, I am not sure how you would go about solving this problem. I tried looking though some docs and googled around and some other people have made the same request in the past as well. I took the easy way out in my applications and just set a java.sql.Timestamp object to the POJO before saving it but I can see why you wouldn't want to tackle it that way.


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.