db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet" <guillaume.no...@deliasystems.com>
Subject RE: Collection prefetching patch
Date Wed, 04 Feb 2004 16:28:59 GMT
Could at least the patch on AbstractPersistentField, that modify the
behavior only
for nested objects could be discussed ?
The only purpose of it, it not to create the nested object, to store an
empty collection
in it, if it is not already created.

Regards,
Guillaume

-----Message d'origine-----
De : Larry V. Streepy, Jr. [mailto:streepy@healthlanguage.com]
Envoye : mercredi 4 fevrier 2004 15:44
A : OJB Users List
Cc : OJB Dev
Objet : Re: Collection prefetching patch


I disagree that this is a proper decision in all cases. There are
semantic reasons why one would want an empty collection versus a null
instance.  If this change is going to be made, the behavior should be
controlled by an attribute of the collection descriptor.

Thanks.
Larry.

Guillaume Nodet wrote:

>I submit another patch that corrects my problem:
>
>In AbstractPersistentField, lines 321 -> 328 replace the code
>
>            String name = fieldName.substring(0, index);
>            PersistentField pField = createInternPersistentField(realClass,
>name);
>            Object attrib = pField.get(realObj);
>
>            if (attrib != null || value != null)
>            {
>                if (attrib == null)
>                {
>
>by the following code:
>
>            String name = fieldName.substring(0, index);
>            PersistentField pField = createInternPersistentField(realClass,
>name);
>            Object attrib = pField.get(realObj);
>
>            if (attrib != null
>                || (value != null
>                    && (!(value instanceof Collection) || ((Collection)
>value).size() > 0)))
>            {
>                if (attrib == null)
>                {
>
>-----Message d'origine-----
>De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
>Envoye : mercredi 4 fevrier 2004 09:40
>A : OJB Users List
>Objet : Collection prefetching patch
>
>
>I saw that ojb do automatically create empty collections and set them to
the
>appropriate field even if they are empty.
>In my own, case, this appears with nested objects, and thus it actually
>creates the nested object despite the fact that it was null when i stored
>the object.
>
>Wouldn't it be better to create the collection only when it is not empty ?
>
>In the CollectionPrefetcher, lines 213 -> 218, there is the following code:
>
>                ManageableCollection col =
>createCollection(collectionClass);
>                for (Iterator it2 = list.iterator(); it2.hasNext();)
>                {
>                    col.ojbAdd(it2.next());
>                }
>                result = col;
>
>What would be the impact to replace it with the following. IMHO, it would
>improve performance a little, and avoid creating unnecessary collections.
>
>                ManageableCollection col = null;
>                for (Iterator it2 = list.iterator(); it2.hasNext();)
>                {
>                    if (col == null)
>                    {
>                        col = createCollection(collectionClass);
>                    }
>                    col.ojbAdd(it2.next());
>                }
>                result = col;
>
>Another way to solve my problem is to implement my own PersistentField
class
>that avoids setting empty collections on nested object if they are not
>created yet, but i guess the one above is better.
>
>Regards,
>
>Guillaume Nodet
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>

--
Larry V. Streepy, Jr.
Senior Vice President and CTO




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