• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate time not being saved through Date

 
Pinal N Patel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

I am not able to save Time(hours, min, secs) information contained in Date object into table using Spring-Hibernate framework. I am mapping my Domain object's java.util.Date property to a date column in the table using type="date". Am I missing something here? The date gets stored in the table but not the time contained in the Date object. Any help is appreciated. Thanks in advance!!

Following is my code snapshot.

 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to store it as a timestamp.

 
Pinal N Patel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't need to store it as a timestamp(actually, depends on the database). If I understand correctly, Date object stores upto seconds and Timestamp upto nanaoseconds.

Just figured it, MySQL with DATE type does not store time info, so I changed it to DATETIME and it worked.

Regards,
Pinal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic