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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to