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.  [ 1 post ] 
Author Message
 Post subject: One second intermittently being added to stored timestamps
PostPosted: Wed May 12, 2010 7:06 pm 
Newbie

Joined: Wed May 12, 2010 4:49 pm
Posts: 1
Using Java 1.6, Hibernate 3, and Oracle 10g, I am seeing the following behavior.

When storing a list of objects that include timestamps as members using saveOrUpdateAll, approximately half the time all timestamps being saved appear in the database with one second added. I am explicitly setting the timestamps' seconds field to 0, but sometimes they show up in the DB as 12:00:00 and sometimes as 12:00:01. It is confusing enough that one second is being added, but the intermittent nature of the problem makes it especially baffling. My searches have uncovered discussion of the difference between java.util.Data and java.sql.Timestamp, the perils of using equals to compare the two, etc. but nothing that seems related to the problem I am seeing. Has anyone seen this behavior? Have I overlooked discussion of this problem elsewhere?

More details follow, in case more details will be helpful. If any additional details will be helpful, ask away!

Class pseudo-code:
Code:
class foo {
  CustomIdClass fooKey;
  java.sql.Timestamp timestamp1;
  java.sql.Timestamp timestamp2;
  various data fields;
  getters+setters;
}
class CustomIdClass {
  long barKey;
  java.sql.Timestamp timestamp1;
  java.sql.Timestamp timestamp2;
  getters+setters;
}

Mapping pseudo-code:
Code:
<class name="foo" table="FOO_TABLE">
   <composite-id class="CustomIdClass" mapped="true">
      <key-many-to-one name="key" column="BAR_PK" lazy="false"/>   
      <key-property name="timestamp1" column="ONE_TS" type="timestamp" />
      <key-property name="timestamp2" column="TWO_TS" type="timestamp" />
   </composite-id>
   <various properties>
</class>

Table definition:
Code:
Column Name  ID   Pk   Null?   Data Type

ONE_TS       1   3   N   TIMESTAMP(0)   
TWO_TS       2   1   N   TIMESTAMP(0)   
BAR_PK       3   2   N   NUMBER (7)      
ETC.         4       Y   NUMBER (7,3)   


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

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.