-->
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.  [ 5 posts ] 
Author Message
 Post subject: Insert "Date" field error on Oracle!
PostPosted: Fri Dec 12, 2003 11:03 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
I have a field in my table, the mapping like following:
@hibernate.property column="AvailDate" type="date"

and in my value object have a method named setAvailDate(java.util.Date date), when I insert a new record, I use the code
Code:
  //start a transaction
  obj.setAvailDate(new java.util.Date());
  //save it
  sess.save(obj);
  sess.commit();


the recode is inserted into database successfully, but this time message of this field is always 12:00:00AM(the date message is OK!).why?

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 11:42 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
because type is "date". If you need FULL time, change it to "timestamp"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 11:14 pm 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
dimas wrote:
because type is "date". If you need FULL time, change it to "timestamp"


dimas, thank you very much!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 13, 2003 1:24 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
now i have another problem about date ot timestamp.

I change my mapping file with timestamp, now it can save full time to database for me.but how can I select some rows with date condition?

I have a table named T_Test that have a field named TestDate,. I defined this field type="timestamp" and I want use following HQL to select from database:

Code:
Date date = //init with a suitable date
List list = conn.find(
    "from com.regical.ecp.db.entity.TransLine line where TerminalDate=?",
    date,   Hibernate.TIMESTAMP);


but i can select nothing. If i change Hibernate.TIMESTAMP to Hibernate.Date in the find method, I can select several data.

What problem with me?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 13, 2003 1:54 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
jzhuo wrote:
Code:
Date date = //init with a suitable date
List list = conn.find(
    "from com.regical.ecp.db.entity.TransLine line where TerminalDate=?",
    date,   Hibernate.TIMESTAMP);



yes, i find the method, because the date variable is a java.util.Date type, it can not compare with java.sql.Timestamp, so i change the variable date to java.sql.Timestamp type, it works fine!

Thanks everybody!


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