aspose file tools*
The moose likes Object Relational Mapping and the fly likes select using hibernate - TIME dataype Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "select using hibernate - TIME dataype" Watch "select using hibernate - TIME dataype" New topic
Author

select using hibernate - TIME dataype

vivek ja
Ranch Hand

Joined: Feb 24, 2005
Posts: 80
I have a column in the database with TIME datatype. THe values in the colums look like 12:06:23 etc., When i try to do a
where >='12:06:23' using winsql it works

But when i try to input the same using my java program using hibernate, when it reaches the hibernate SQLLoader file, it chaanges this value to
'12?' and gives error:
"The syntax of the string representation of a datetime value is incorrect."

I have tried declaring it as String, java.sql.Time, java.sql.Timestamp.
Nothing works. Anyone has any different ideas to make it work?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


when it reaches the hibernate SQLLoader file

Are you saying you are using Hibernate and SQLLoader together? I think you will have to tell us a little more about what you are doing. Can you post the code that fails?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jonathan Huang
Ranch Hand

Joined: Jun 23, 2006
Posts: 35
You also have to remember that if you have a Timestamp in the DB and take it out, Hibernate takes it as a date, you lose precision... Or am I backwards?

Anywho, to keep your precision you need to write a custom type to type cast properly.

There are some good dicusions of this at the official forums.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


You also have to remember that if you have a Timestamp in the DB and take it out, Hibernate takes it as a date, you lose precision... Or am I backwards?

Huh? Where did you hear this? java.sql.Date represents a SQL date data type, which has no hours, minutes, etc. So if you mapped a timestamp data type to a java.sql.Date you could loose precision that way. Also older (now-unsupported) JDBC drivers for Oracle had bugs in their Timestamp handling.

But then again, perhaps I've missed something in the Hibernate forums. You say there are discussions in there about this; could you point us at one?
[ October 05, 2006: Message edited by: Paul Sturrock ]
Jonathan Huang
Ranch Hand

Joined: Jun 23, 2006
Posts: 35
I don't think I was very accurate in my description of the problem but hopefully these will remedy my ignorance.

http://forum.hibernate.org/viewtopic.php?t=927602&highlight=timestamp+date+sql

http://forum.hibernate.org/viewtopic.php?t=925275&highlight=timestamp+date+sql
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select using hibernate - TIME dataype