db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: Problems with TransactionExt.flush
Date Fri, 23 Jul 2004 11:32:16 GMT
Hi Charles,

this was my fault. Introduce this after rc4 to improve performance, but 
I wasn't aware of the side-effect - sorry.
Will check in your patch asap.

regards,
Armin

Charles Anthony wrote:
> Hi,
> 
> I've found that my hunch seems to be correct; if you comment out line 409 of
> ObjectEnvelope (the line that says if(hasChanged == null) ) the test passes.
> I'm not suggesting it's the right solution, just that  the hasChanged flag
> is what's causing the problem.
> 
> Cheers,
> 
> Charles
> 
> 
>     public boolean hasChanged()
>     {
> //        if(hasChanged == null)
>         {
>             Map currentImage = null;
>             try
>             {
>                 currentImage = getMap();
>             }
>             catch(Exception e)
>             {
>                 LoggerFactory.getDefaultLogger().warn("Could not verify
> object changes, return hasChanged 'true'", e);
>             }
> 
>             hasChanged = (beforeImage != null &&
> beforeImage.equals(currentImage) ? Boolean.FALSE : Boolean.TRUE);
>         }
>         return hasChanged.booleanValue();
>     }
> 
> 
>>-----Original Message-----
>>From: Charles Anthony [mailto:charles.anthony@hpdsoftware.com]
>>Sent: 22 July 2004 13:12
>>To: 'ojb-dev@db.apache.org'
>>Subject: Problems with TransactionExt.flush
>>
>>
>>Hi,
>>
>>I've got a quite big (and urgent) problem with the odmg 
>>TransactionExt.flush
>>method. In many places in our app we 
>>1. lock an object to the transaction
>>2. we *don't* modify it, 
>>3. flush the tx, 
>>4. modify it
>>5. then commit. 
>>
>>With CVS Head (and, I suspect, the release version), the 
>>commit does not
>>write the changes to the database (whereas our version from 
>>Sept last year
>>does). If I remove the flush, it gets written correctly.
>>
>>I have modified 
>>org.apache.ojb.odmg.ODMGRollbackTest.testTransactionFlush
>>method to reproduce the error. The modified method follow this email.
>>
>>I think (but I haven't checked) it is to do with the
>>ObjectEnveloper.hasChanged being set to FALSE on the flush - 
>>then not being
>>reset to null, so that when we commit 
>>ObjectEnveloper.hasChanged immediately
>>returns false instead of checking the maps.
>>
>>Cheers,
>>
>>Charles
>>
>>
>>    public void testTransactionFlush() throws Exception
>>    {
>>        TransactionExt tx = (TransactionExt) odmg.newTransaction();
>>
>>        tx.begin();
>>        PersistenceBroker broker = tx.getBroker();
>>
>>        ODMGZoo obj = new ODMGZoo();
>>        tx.lock(obj, Transaction.WRITE);
>>        obj.setName("testTransactionFlush");
>>
>>        tx.flush();
>>
>>        Criteria crit = new Criteria();
>>        crit.addEqualTo("name", obj.getName());
>>        QueryByCriteria query = 
>>QueryFactory.newQuery(ODMGZoo.class, crit);
>>        // we flushed all objects, thus we should found 
>>object in DB/cache
>>        Iterator it = broker.getIteratorByQuery(query);
>>        assertTrue(it.hasNext());
>>        assertSame(obj, it.next());
>>        assertFalse(it.hasNext());
>>
>>        /*** Charles : Start ***/
>>        // Let's flush, change the name and flush again
>>        tx.flush();
>>        obj.setName("testTransactionFlushCHANGED");
>>        tx.flush();
>>        //Redo the query - we should find the object again
>>        crit = new Criteria();
>>        crit.addEqualTo("name", obj.getName());
>>        query = QueryFactory.newQuery(ODMGZoo.class, crit);
>>        // we flushed all objects, thus we should found 
>>object in DB/cache
>>        it = broker.getIteratorByQuery(query);
>>        assertTrue("Should find object",it.hasNext());
>>        assertSame(obj, it.next());
>>        assertFalse(it.hasNext());
>>        /*** Charles : End ***/
>>
>>        // now we abort tx, so all flushed objects shouldn't be found
>>        // in further queries
>>        tx.abort();
>>
>>        tx = (TransactionExt) odmg.newTransaction();
>>        tx.begin();
>>        broker = tx.getBroker();
>>        QueryByIdentity query2 = new QueryByIdentity(obj);
>>        Object result = broker.getObjectByQuery(query2);
>>        tx.commit();
>>
>>        assertNull("We should not find objects from aborted 
>>tx", result);
>>
>>        
>>
>>    }
>>
>>
>>___________________________________________________________
>>HPD Software Ltd. - Helping Business Finance Business
>>Email terms and conditions: www.hpdsoftware.com/disclaimer 
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
> 
> 
> 
> ___________________________________________________________
> HPD Software Ltd. - Helping Business Finance Business
> Email terms and conditions: www.hpdsoftware.com/disclaimer 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
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