Hey all, 
i'm new in jdo and castor ! Now i've persist my first data. Read and
insert works, but there is a problem with update. I wan't optimistic
Locking. 
 
I do something like this:
 
private void update(BaseVO baseVo)  throws ...
{
      try 
      {
            db = jdo.getDatabase();
            db.begin();
            
            OQLQuery query = getQuery(baseVo.getId());                 
            QueryResults results = query.execute();

            BaseVO baseVoFromDB = (BaseVO)results.next();
                  
            Integer version = baseVo.getVersion();
            Integer versionInDB = baseVoFromDB.getVersion();
                  
            if( ! version.equals( versionInDB ) )
            {
                  System.out.println("Version in DB: " + versionInDB );
                  System.out.println("Version in RAM: " + version );
                  throw new OptimisticLockingException();
            }
 
            int primitiveVersion = version.intValue();                 
            baseVo.setVersion( new Integer( ++primitiveVersion ) );
                  
// HERE IS THE PROBLEM !!!
            baseVoFromDB = baseVo; 
// DO I HAVE TO MAP ALL ATTRIBUTES ?? OR IS THERE ANY OTHER WAY ?
                  
            db.commit();
            db.close();
      } 
      catch (PersistenceException e) 
      {
            throw new ...
      }
}
 
 
 
The errormessage says something about timestampable objects !!! Where
can i read more about it ?
 
 
Fredy

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to