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 John M <wu...@mailandnews.com> on 2003/06/30 20:19:47 UTC

PB marked for delete

I had a problem where items were not being deleted correctly.  I found out the 
problem was in the equals method of my base item class.  The check in 
PersistenceBrokerImpl.delete for presence in markedForDelete was finding the 
wrong things.  My equals was definitely broken, but I don't know if the docs 
have much to say about the best way to override things like hashCode and 
equals for persistable classes.  Would that be something to make a note of?  
Are there other areas where the behavior of these methods could affect things?
 My classes use the class and pk fields for equals and hashCode.  Does this 
sound pretty standard?

While I was looking into this I noticed that markedForDelete is an ArrayList, 
which needs to loop all elements until a match for contains.  I swapped this 
with a HashSet and realized a small performance gain (8% on two runs) on the 
performance test (ant performance).  Then of course the burden of correct 
implementation moves from equals to hashCode.

John Marshall
Connectria