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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Larry V. Streepy, Jr. Senior Vice President and CTO