my dog learned polymorphism
The moose likes Object Relational Mapping and the fly likes JPA+Oracle+Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA+Oracle+Date" Watch "JPA+Oracle+Date" New topic


Kamil Ka

Joined: Sep 01, 2009
Posts: 3
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

Joined: Feb 05, 2001
Posts: 17271

In Annotations it would be using @Temporal like

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Kamil Ka

Joined: Sep 01, 2009
Posts: 3
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

Joined: Jun 13, 2008
Posts: 4
Just changed it to @Temporal(TemporalType.TIME)

"Sanity calms, but madness is more interesting."<br />- John Russell
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JPA+Oracle+Date
It's not a secret anymore!