will test later then reply tthe result in a few days,tks.

Best Regards

johnson
----- Original Message ----- From: "Armin Waibel" <[EMAIL PROTECTED]>
To: "OJB Users List" <[email protected]>
Sent: Tuesday, June 14, 2005 9:47 PM
Subject: Re: org.odmg.LockNotGrantedException


Hi again,

Johnson wrote:
Hi!

tks your help I use OJB in cocoon tmocat here's the code.
this code is work on 1.0.1 but not work in 1.0.3.


I can't reproduce the problem with latest from CVS (OJB_1_0_RELEASE
branch). I wrote two tests simulating the problem, first test doesn't
find a query object and lock the bean object, second test return a dummy
object in query. Both tests pass.

I attached the tests below (the test can be found in CVS OJB_1_0_RELEASE
branch, LockingTest#testWrite_X). Are these tests different from your
problem? Could you locally setup a test case to reproduce the problem?
Are you able to test upcoming OJB 1.0.4 from CVS?

regards,
Armin




public void testWrite_1() throws Exception
{
   String name = "testWrite_1_" + System.currentTimeMillis();
   LockObject bean = new LockObject(name + "_bean_dummy");

   performCocoonSaveMethod(bean.getId(), bean);

   Transaction tx = odmg1.newTransaction();
   tx.begin();
   OQLQuery query = odmg1.newOQLQuery();
   query.create("select objs from " + LockObject.class.getName() + "
where value = $1");
   query.bind(name + "_bean_dummy");
   List result = (List) query.execute();
   tx.commit();
   assertEquals(1, result.size());
   LockObject tmp = (LockObject) result.get(0);
   assertEquals(bean, tmp);
}

public void testWrite_2() throws Exception
{
   String name = "testWrite_2_" + System.currentTimeMillis();

   Transaction tx = odmg1.newTransaction();
   tx.begin();
   LockObject tmp = new LockObject(name + "_temp");
   db1.makePersistent(tmp);
   tx.commit();

   LockObject bean = new LockObject(name + "_bean_dummy");
   bean.setId(tmp.getId());

   performCocoonSaveMethod(tmp.getId(), bean);

   tx = odmg1.newTransaction();
   tx.begin();
   OQLQuery query = odmg1.newOQLQuery();
   query.create("select objs from " + LockObject.class.getName() + "
where value = $1");
   query.bind(name + "_bean_dummy");
   List result = (List) query.execute();
   tx.commit();
   assertEquals(1, result.size());
   tmp = (LockObject) result.get(0);
   assertEquals(bean, tmp);
}

private LockObject performCocoonSaveMethod(Integer testId, LockObject
bean) throws Exception
{
   LockObject toBeEdited = null;
   Transaction tx = odmg1.newTransaction();
   tx.begin();
   OQLQuery query = odmg1.newOQLQuery();
   query.create("select objs from " + LockObject.class.getName() + "
where id = $1");
   query.bind(testId);
   List result = (List) query.execute();
   if(result.size() != 0)
   {
       toBeEdited = (LockObject) result.get(0);
       if(toBeEdited != null)
       {
           try
           {
               PropertyUtils.copyProperties(toBeEdited, bean);
               tx.commit();
           }
           catch(Exception e)
           {
               e.printStackTrace();
               fail("Unexpected exception: " + e.getMessage());
           }
           tx.begin();
           tx.lock(toBeEdited, Transaction.UPGRADE);
           tx.commit();
       }
       else
       {
           tx.abort();
       }
   }
   else
   {
       try
       {
           tx.lock(bean, Transaction.WRITE);
           tx.commit();
       }
       catch(Exception e)
       {
           e.printStackTrace();
           fail("Unexpected exception: " + e.getMessage());
       }
   }
   return toBeEdited;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to