db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
Date Mon, 21 Jun 2004 21:16:27 GMT
arminw      2004/06/21 14:16:26

  Modified:    src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
  Log:
  apply path for optimistic locking problem by Martin KalÚn:
  
  Looking at ClassDescriptor.java, lines 949 and 950 in method updateLockingValues,
  one sees that the locking timestamp is created using "new java.sql.Timestamp(long)".
  
  If doing this is seems that at least for Oracle JDBC thin driver, the naonsecond
  part of the Timestamp can be initialized to values != 0.
  
  Since Oracle TIMESTAMP does not have nanosecond precision, the value for comparision
  when reading back from the DB will _always_ have Timestamp.getNanos() == 0.
  
  Hence; the timestamp in memory and the comparision value read from the db will differ
  and OptimisticLockingException thrown were it should not.
  
  Revision  Changes    Path
  1.88      +4 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- ClassDescriptor.java	14 Jun 2004 18:31:56 -0000	1.87
  +++ ClassDescriptor.java	21 Jun 2004 21:16:26 -0000	1.88
  @@ -947,7 +947,9 @@
                   else if (f.getType() == Timestamp.class)
                   {
                       long newCv = (new Date()).getTime();
  -                    f.set(obj, new Timestamp(newCv));
  +                    Timestamp ts = new Timestamp(newCv);
  +                    ts.setNanos(0);
  +                    f.set(obj, ts);
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message