db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: RemovalAwareCollection and clear()
Date Fri, 25 Feb 2005 21:23:37 GMT
hi martin,

i refactored the ojb-collections  for ojb 1.1. the ojb-collections are 
no longer subclasses, they are implemented as wrappers.
could you plese have a look at it ?

jakob

Martin Kalén schrieb:

> Greetings,
>  while running the test suite for OJB_1_0_RELEASE-branch with the 
> patched Torque, I noticed that both oracle9 and hdqldb profiles were 
> failing in one OTM test case, namely:
>
> SwizzleTests#testSwizzle1toN
>
> I think this test was written when ProductGroup was mapped to Article 
> without proxy objects, and so on line 351 the test asserts that:
> "size of all articles in product group = 0" after performing a 
> clear()-call on the product group collection of articles.
>
> Since the mapping is now using proxy objects, there will be a 
> RemovalAwareCollection in place, which does _NOT_ overload the clear() 
> call defined in java.util.Vector.
>
> Hence:
> 1. take a removal aware collection with size > 0
> 2. issue collection.clear()
> 3. check collection.size() and you will get a value > 0
>
> To me this smells wrong. ;) RemovalAwareCollection extends 
> java.util.Vector and should be bound by the same API contract, right?
> A check with Sun (vector is no news so 1.3.1 will do):
> http://java.sun.com/j2se/1.3/docs/api/java/util/Vector.html#clear()
> "public void clear()
>
>     Removes all of the elements from this Vector. The Vector will be 
> empty after this call returns (unless it throws an exception)."
>
> Not true for RAC as stated in the 1,2,3-example above.
>
>
> If I add this to RAC:
>     /**
>      * @see java.util.Vector#clear()
>      */
>     public void clear()
>     {
>         removeAllElements();
>         super.clear();
>     }
>
> The elements will indeed be registered for removal when someone calls 
> .clear(), but when I set a breakpoint in RAC#afterStore there is a 
> call that effectively reverses this operation.
>
> The comment says "make sure allObjectsToBeRemoved does not contain any 
> instances that got re-added to the list". To me that does not compute, 
> so I am a bit unsure how to go ahead with this...
>
> Could someone that know how RAC and/or OTM _should_ work go ahead with 
> this?
>
> Regards,
>  Martin
>
> P.S. If anyone does make a change to RAC, please remove the TODO at 
> line  50 since line 51 is already (as of 2003-04-09, r1.2) doing what 
> the TODO says.
>
> ---------------------------------------------------------------------
> 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