-->
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: Unable to persist Milliseconds from Hibernate to Oracle DB
PostPosted: Wed Feb 18, 2009 6:02 pm 
Newbie

Joined: Wed Feb 18, 2009 5:47 pm
Posts: 2
I am trying to persist data using Hibernate and which includes a timestamp field with milliseconds upto length 6.

I want to persist [b]yyyy-MM-dd HH:mm:ss:SSSSSS[/b] format, my input string is [b]2008-11-15-09.31.16.469000[/b].

But after hibernate persistance in the database the field seems to looses milliseconds and only posts it as 2008-11-15-09.31.16.000000.

The HBM mapping file is already mapped to java.sql.Timestamp as



<property name="myTimeStampField" type="java.sql.Timestamp">
<column name="MY_TIME_COL" length="7" not-null="true" />
</property>


I tried to run a update in Oracle 9i with this date format and value, Oracle can update the values if I run it as a seperate querry in Oracle console.

Hibernate is not able to persist the value with the timestamps.

I think this is a known issue with Hibernate, any thoughts how i can persist the milliseconds in the MY_TIME_COL ?

My Oracle Table has the MY_TIME_COL as TIMESTAMP(6) type and length, so it can update and store timestamps.

Any help most appreceated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 2:20 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
The limit is not with hibernate but with java.sql.Timestamp. The millisecond field of Timestamp field can hold only upto 999. And I dont understand why some one would require more than 999 for millisecond field coz 1000 ms = 1 sec.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject: Question is not how many milisecond fields it can persist
PostPosted: Thu Feb 19, 2009 9:51 am 
Newbie

Joined: Wed Feb 18, 2009 5:47 pm
Posts: 2
Question is not how many milisecond field it can persist, but rather it cannot persist any miliseconds, changing the format to have yyyy-MM-dd HH:mm:ss:SSS format from the previous yyyy-MM-dd HH:mm:ss:SSSSSS does not help either.

It still persists the ,miliseconds as 000000


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 6:23 pm 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
try to use "timestamp" (the hibernate type) instead of "java.sql.Timestamp".
Also i'm not sure how the length affects the storing of values.
You might also check for the dialect you are using, although i guess even older oracle versions know how to deal with timestamp

Hope that helps, rating is welcome


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.