Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA+Oracle+Date

 
Kamil Ka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How shuold I map oracle Date type to java.util.Date without lossing hours, minutes and seconds. I musn't change oracle date type to timestamp

I'll be grateful for suggestions
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Annotations it would be using @Temporal like

http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e342

there is an equivalent in xml, just check out the Hibernate docs.

Mark
 
Kamil Ka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for replay,
I know about @Temporal annotation, but if I use @Temporal(TemporalType.DATE) I get java.util.Date with default time 12:00:00.

For example:
In oracle database is saved following date: 01-01-2009 01:30:12. If I use above annotation, I'll get date 01-01-2009 00:00:00 (because TemporalType.DATE map to java.sql.Date)
If I use annotation with timestamp, I'll get exception. As I mentioned earlier, I can't change field type in database to timestamp
 
Diego Magalhães
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just changed it to @Temporal(TemporalType.TIME)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic