db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject PersistentField and primitives
Date Sat, 21 Jun 2003 13:37:15 GMT
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


Mime
View raw message