• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select using hibernate - TIME dataype

 
vivek ja
Ranch Hand
Posts: 80
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Jonathan Huang
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic