wood burning stoves 2.0*
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
Author

JPA+Oracle+Date

Kamil Ka
Greenhorn

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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


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

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
Greenhorn

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


"Sanity calms, but madness is more interesting."<br />- John Russell
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA+Oracle+Date
 
Similar Threads
java.sql.Timestamp to Oracle date
inserting a string containing date into oracle table which has the date type field
what's the difference?
Conversion
Timestamp problem