-->
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: Insert the SYSDATE into Oracle database using objects
PostPosted: Thu Apr 16, 2009 11:12 am 
Newbie

Joined: Wed Mar 25, 2009 10:12 pm
Posts: 4
My hbm.xml file:

<property name="startDate" type="timestamp" formula="(select sysdate from dual)">
<column length="7" name="START_DATE"/>



My Query:

Query query=session.createQuery("Select U.startDate from UsercertificationDetails U");
List dateList=query.list();
Date startDate=(Date)dateList.get(0);
System.out.println("Date is: "+startDate);

This is printing the correct syatem date with correct time.

ob.setDate(startDate); //I assigned the startDate into an object.
System.out.println(ob.getDate); //The valus has been uploaded into object.

then i gave
session.save(ob);


ob have someother values also.
In database all the other values in ob has been successfully uploaded except startDate.

Can somebody help me to solve this?


Top
 Profile  
 
 Post subject: Error solved
PostPosted: Thu Apr 16, 2009 11:35 am 
Newbie

Joined: Wed Mar 25, 2009 10:12 pm
Posts: 4
Change the hbm file property.

Set default="sysdate" and insert="false".
Then the sysdate will be inserted into table.


Top
 Profile  
 
 Post subject: Re: Insert the SYSDATE into Oracle database using objects
PostPosted: Tue Oct 25, 2011 8:49 am 
Newbie

Joined: Tue Oct 25, 2011 8:45 am
Posts: 1
hi admirer,
I have done the same thing which you have written below. Me too faced the same problem. But what I have done after it is, I created one extra property and given the formula. and save that date to the column.

please find the code which I have pasted in below URL

http://stackoverflow.com/questions/7499 ... -hibernate


Thanks & Regards
Naveen


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.