db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: VOTE: PersistentField and primitives
Date Mon, 23 Jun 2003 19:14:54 GMT
Hi all,

Jakob Braeuchi wrote:
> 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.

+1

as you mentioned in your other mail it could be useful to make the 
behaviour configurable.

cheers,
Thomas

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