• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Hibernate time not being saved through Date  RSS feed

 
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.

 
Sheriff
Posts: 10445
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
Boost this thread!