You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Mark Neighbors <mn...@visualanalytics.com> on 2003/06/04 18:20:09 UTC

Problems with DMap

Hi,

I'm having problems with TransactionImpl.markDelete(Object anObject)
regarding keys to DMAP entries as well as the DMap Impl object itself.

markDelete will sometimes not cause an sql DELETE for these objects at
transaction commit. However, the Entry object always get deleted.

The persistent key class contains a pk field and a string value field.  The
equals and hashCode methods are overridden to implement value-based
equality on the string value field only, thus ignoring the pk field.

I discovered this problem with markDelete sometime earlier and worked around
it by dropping down to the lower layer with

      sql = "DELETE FROM OJB_DMAP WHERE ID = " + ((DMapImpl)object).getId() ;
      persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;

      sql = "DELETE FROM PSTRING WHERE ID = " + ((PersistentString)object).getID() ;
      persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;

Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE)
regarding persistent string keys and persistent string values.  lock will
sometimes not cause an sql INSERT at transaction commit.  The map entry objects
get inserted by the string keya and values do not.

I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values.
the TransactionImpl.put method only locks the key and value for REEAD.

I have verified the actual generated sql via the postgresql log.

Can anybody help?

Thanks in advance,
Mark

Re: Problems with DMap

Posted by Mark Neighbors <mn...@visualanalytics.com>.
I can't send the actual code.  Duplicating the error in an autonomous test
may be probematic.  It could be due to some mechanism (mine or ojb's)
that doesn't get repesented in the autonomous environment.

The only other alternatives I can think of at this point are to attempt working
around it with pb operations, and to write a variation of DMap that stores the
string key directly in the map entry table.

And so since I'm under the gun at this point I need to decide which avenue to
take.  I'm leaning toward attempting to avoid the problem by getting rid of persistent
strings as keys/values.  However this won't avoid the problem of deleting the OJB_DMAP
row, which will probably still need to be done with the pb.

If I can't work around it I'll attempt to duplicate the error.

----- Original Message ----- 
From: "Thomas Mahler" <th...@web.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Wednesday, June 04, 2003 2:37 PM
Subject: Re: Problems with DMap


> Hi Mark,
> 
> can you post a piece of code demonstrating the failure?
> I'd like to verify this with a test case.
> 
> cheers,
> thomas
> 
> Mark Neighbors wrote:
> > Hi,
> > 
> > I'm having problems with TransactionImpl.markDelete(Object anObject)
> > regarding keys to DMAP entries as well as the DMap Impl object itself.
> > 
> > markDelete will sometimes not cause an sql DELETE for these objects at
> > transaction commit. However, the Entry object always get deleted.
> > 
> > The persistent key class contains a pk field and a string value field.  The
> > equals and hashCode methods are overridden to implement value-based
> > equality on the string value field only, thus ignoring the pk field.
> > 
> > I discovered this problem with markDelete sometime earlier and worked around
> > it by dropping down to the lower layer with
> > 
> >       sql = "DELETE FROM OJB_DMAP WHERE ID = " + ((DMapImpl)object).getId() ;
> >       persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;
> > 
> >       sql = "DELETE FROM PSTRING WHERE ID = " + ((PersistentString)object).getID() ;
> >       persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;
> > 
> > Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE)
> > regarding persistent string keys and persistent string values.  lock will
> > sometimes not cause an sql INSERT at transaction commit.  The map entry objects
> > get inserted by the string keya and values do not.
> > 
> > I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values.
> > the TransactionImpl.put method only locks the key and value for REEAD.
> > 
> > I have verified the actual generated sql via the postgresql log.
> > 
> > Can anybody help?
> > 
> > Thanks in advance,
> > Mark
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

Re: Problems with DMap

Posted by Thomas Mahler <th...@web.de>.
Hi Mark,

can you post a piece of code demonstrating the failure?
I'd like to verify this with a test case.

cheers,
thomas

Mark Neighbors wrote:
> Hi,
> 
> I'm having problems with TransactionImpl.markDelete(Object anObject)
> regarding keys to DMAP entries as well as the DMap Impl object itself.
> 
> markDelete will sometimes not cause an sql DELETE for these objects at
> transaction commit. However, the Entry object always get deleted.
> 
> The persistent key class contains a pk field and a string value field.  The
> equals and hashCode methods are overridden to implement value-based
> equality on the string value field only, thus ignoring the pk field.
> 
> I discovered this problem with markDelete sometime earlier and worked around
> it by dropping down to the lower layer with
> 
>       sql = "DELETE FROM OJB_DMAP WHERE ID = " + ((DMapImpl)object).getId() ;
>       persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;
> 
>       sql = "DELETE FROM PSTRING WHERE ID = " + ((PersistentString)object).getID() ;
>       persistenceBroker.deleteByQuery (new QueryBySQL(DMapImpl.class, sql)) ;
> 
> Now I just discovered a similar problem with TransactionImpl.lock(Object obj, Transaction.WRITE)
> regarding persistent string keys and persistent string values.  lock will
> sometimes not cause an sql INSERT at transaction commit.  The map entry objects
> get inserted by the string keya and values do not.
> 
> I am explicitly calling txn.lock(obj, Transaction.WRITE) on the keys and values.
> the TransactionImpl.put method only locks the key and value for REEAD.
> 
> I have verified the actual generated sql via the postgresql log.
> 
> Can anybody help?
> 
> Thanks in advance,
> Mark
>