-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Can't figure out mapping from Oracle TIMESTAMP to Date
PostPosted: Mon Dec 25, 2006 4:28 am 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
JDK 1.4.2, Hibernate 3.0.5.

I know this has probably been rehashed many times, but I'm not sure what I'm doing wrong.

I have a column defined as an Oracle TIMESTAMP. When I view it in my SQL browser (SQuirreL), the value looks ok ("2006-12-24 20:54:30.0", for instance).

I defined the column in my HBM file like:

<property name="modTime" column="MOD_TIME" type="timestamp"/>

In the bound class, I defined the field as a "java.util.Date" field. When I print the value of the field, it appears to be something like "2006-09-29 17:32:29.0". Is it supposed to be bound to a Calendar object instead?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 01, 2007 12:06 pm 
Newbie

Joined: Mon Dec 25, 2006 3:14 pm
Posts: 18
You should use "calendar".

checkout: http://ndpsoftware.com/HibernateMappingCheatSheet.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 01, 2007 2:03 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
I've seen this page many times, and the way I read it, if you are using SQL type TIMESTAMP, you can map it to either java.util.Date or java.util.Calendar. I was using Date.

In any case, since my db types are constrained, but I could easily change the class it maps to, and the class is in a "db mapping layer", I simply mapped it to java.sql.Timestamp, which ended up working fine.

On the other hand, along the way I also discovered a coding issue I had in how I was referencing the mapped objects, which I fixed. It's possible I could go back to java.util.Date with no problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 01, 2007 2:37 pm 
Newbie

Joined: Mon Dec 25, 2006 3:14 pm
Posts: 18
> It's possible I could go back to java.util.Date with no problem

because java.util.Date is parent of Timestamp.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.