db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject VOTE: PersistentField and primitives
Date Mon, 23 Jun 2003 18:20:39 GMT
hi all,

how should we treat primitive values in PersistentField when set(null) 
is required.
the current solution simply ignores set() in this case, which leads to 
problems described below.
imo setting primitives to 0 (zero) should be acceptable.

what do you think ?

jakob

Jakob Braeuchi wrote:

> hi,
>
> while working on a testcase i stumbled across a problem with 
> primitives used a reference ids.
>
> AbstractArticle has  an int instvar containing the id of the productgroup
> ...
>    protected int productGroupId;
> ...
>
> in the testcase i tried to set the productgroup of an article to null:
>
>
>        // clear ProductGroup
>        b.setProductGroup(null);
>        storeArticle(b);
>                       broker.clearCache();             b = 
> readArticleByIdentity(testId);
>        assertEquals("should be null after update", null, 
> b.getProductGroup());
>
>
> this testcase fails because the productGroupId is NOT updated in 
> PersistentFieldDefaultImpl#set.
> this behaviour is also documented in this method:
>
>            /**
>             * MBAIRD
>             * we need to be able to set values to null. We can only 
> set something to null if
>             * the type is not a primitive (assignable from Object).
>             */
>            if ((value != null) || !type.isPrimitive())
>            {
>                f.set(ProxyHelper.getRealObject(obj), value);
>            }
>
>
> imo we should at least issue a warning or find a better solution.
>
> jakob
>
>
> ---------------------------------------------------------------------
> 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