You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Jakob Braeuchi <jb...@gmx.ch> on 2003/06/21 15:37:15 UTC

PersistentField and primitives

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


Re: VOTE: PersistentField and primitives

Posted by Thomas Mahler <th...@web.de>.
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
> 
> 


VOTE: PersistentField and primitives

Posted by Jakob Braeuchi <jb...@gmx.ch>.
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
>
>


Re: howto-get-started.xml patch

Posted by Armin Waibel <ar...@code-au-lait.de>.
----- Original Message -----
From: "Brian McCallister" <mc...@forthillcompany.com>
To: "OJB Developers List" <oj...@db.apache.org>
Sent: Sunday, June 22, 2003 7:56 PM
Subject: howto-get-started.xml patch


> Ack, how embarrassing. Linked to local filesystem in a howto!
>

is done!
As long as you don't 'link' to your
VisaCard number, I don't see a
embarrassing situation ;-)

regards,
Armin

> Patch is inlined since I cannot seem to attach files ot this list.
>
> --------
> Patch below
> --------
>
> Index: xdocs/howto-get-started.xml
> ===================================================================
> RCS file: /home/cvspublic/db-ojb/xdocs/howto-get-started.xml,v
> retrieving revision 1.1
> diff -u -r1.1 howto-get-started.xml
> --- xdocs/howto-get-started.xml 2 Apr 2003 20:23:10 -0000 1.1
> +++ xdocs/howto-get-started.xml 22 Jun 2003 17:53:37 -0000
> @@ -187,7 +187,7 @@
>   In addition to the configuration information, you will need the ojb
> jar
>   library, and its required libraries. An up to date list of these is
> kept
>   on the
> - <a
> href="file://localhost/Users/mccallister/src/ojb/db-ojb/target/doc/
> deployment.html#4">
> + <a href="deployment.html#4">
>   Deployment</a> page. Copy these jar files to your runtime classpath
> as
>   well as the db-ojb-*.jar.
>   </p>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>



howto-get-started.xml patch

Posted by Brian McCallister <mc...@forthillcompany.com>.
Ack, how embarrassing. Linked to local filesystem in a howto!

Patch is inlined since I cannot seem to attach files ot this list.

--------
Patch below
--------

Index: xdocs/howto-get-started.xml
===================================================================
RCS file: /home/cvspublic/db-ojb/xdocs/howto-get-started.xml,v
retrieving revision 1.1
diff -u -r1.1 howto-get-started.xml
--- xdocs/howto-get-started.xml	2 Apr 2003 20:23:10 -0000	1.1
+++ xdocs/howto-get-started.xml	22 Jun 2003 17:53:37 -0000
@@ -187,7 +187,7 @@
  		In addition to the configuration information, you will need the ojb  
jar
  		library, and its required libraries. An up to date list of these is  
kept
  		on the
-		<a  
href="file://localhost/Users/mccallister/src/ojb/db-ojb/target/doc/ 
deployment.html#4">
+		<a href="deployment.html#4">
  		Deployment</a> page. Copy these jar files to your runtime classpath  
as
  		well as the db-ojb-*.jar.
  	</p>