-->
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.  [ 5 posts ] 
Author Message
 Post subject: no oracle date mapping to java.util.Date?
PostPosted: Wed Sep 14, 2005 9:38 am 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
Hi,
looking at:
http://www.hibernate.org/hib_docs/v3/re ... basictypes

I want to map a java.util.Date to a date in oracle and I want the value to maintain it's "fullness" in oracle. The only hibernate types I've found that use a date in oracle are date, time, and calendar_date, but none of these work for me. Here's why:

date: doesn't preserve time when inserting into oracle
time: doesn't preserve date when inserting into oracle
calendar_date: I want a java.util.Date - not a Calendar

Am I missing the proper way to do this mapping?

Thanks,
Ben

ps - I'm using hibernate 3.0.5 and oracle 9.0.2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 10:42 am 
Newbie

Joined: Wed Sep 14, 2005 10:38 am
Posts: 2
Hrmmm... we use the timestamp type in our mapping files with oracle and it works file with java.util.Date...

Why doesn't that work for you?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 11:25 am 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
That doesn't work because a dba is creating the ddl for us. I'm the one pushing us to use hibernate on this project. I don't want to push back and say, "we need to change to db structure because hibernate won't work as it currently is". If I have to go this route I will, but I figured I'd check and see if I didn't need to do this. Every oracle database I've seen has used the date type (not timestamp). I would think this should be pretty straight forward for hibernate to handle.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 11:36 am 
Newbie

Joined: Wed Sep 14, 2005 10:38 am
Posts: 2
Right... I think you're misunderstanding me...

In Oracle the type of the column is Date (looks like "2005-07-12 14:02:24")

In your hbm.xml file make the property type timestamp

Then in java use java.util.Date

That should give you the precision you need.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 12:07 pm 
Beginner
Beginner

Joined: Wed Sep 14, 2005 9:11 am
Posts: 22
yes, I misunderstood you :-)

Yes, that will work. I mis-diagnosed my problem. I should've mentioned that my assumption of hibernate was my mapping of hbm.xml files to ddl. It creates a timestamp column type if you use the timestamp hibernate type. That doesn't imply that the mapping wouldn't work with a date column type (which is what you're saying and I was incorrect in assuming). Thanks for the clarification. :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.