Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#15 wrong destination object for list of custom converted object

closed
None
5
2005-10-31
2005-10-19
Anonymous
No

When mapping from list to list and the contents of
those lists use a custom converter than the destination
object passed to that converter is the parent list
rather than the element. The destination class is correct.

When using an iterated mapping all the converter's
parameters are correct. One immediate difference is
that mapUsingCustomConverter is being called with
toplevel=true in this case and false in the invalid case.

Because the path is somewhat different in those cases I
haven't been able to narrow down the problem.

When destination is wrong the call stack looks like:

mapUsingCustomConverter(Class, Object, Class, ClassMap,
Object, FieldMap, boolean)
mapOrRecurseObject(Object, Class, ClassMap, FieldMap,
Object)
addOrUpdateToList(FieldMap, Collection, ClassMap, Object)
mapListToList(List, ClassMap, FieldMap, Object)
mapCollection(Object, ClassMap, FieldMap, Object)
mapOrRecurseObject(Object, Class, ClassMap, FieldMap,
Object)
mapFromMethodFieldMap(Object, Object, ClassMap, FieldMap)
map(Object, Object, ClassMap, FieldMap)
map(Object, Class, FieldMap)

And when iterating (destination correct) it looks like:

mapUsingCustomConverter(Class, Object, Class, ClassMap,
Object, FieldMap, boolean)
map(Object, Object, ClassMap, FieldMap)
map(Object, Object, ClassMap)
map(Object, Class)
mapFromIterateMethodFieldMap(Object, Object, ClassMap,
FieldMap)
map(Object, Object, ClassMap, FieldMap)
map(Object, Object, ClassMap)
map(Object, Class)

Rohan

Discussion

    • assigned_to: nobody --> fgarsombke
     
  • Logged In: YES
    user_id=550744

    This looks fun...! I will try to reproduce this. Any test
    data I can have to reproduce the problem?

    Thanks.

    Franz

     
  • Logged In: YES
    user_id=550744

    I have tested List to List with converter (our test case
    testCustomConverterMapping on MapperTest.java)
    and it seems to work fine. Can you give me your test
    objects, test data, and mapping config file? Or some more
    information...

    Thanks.

    Franz

     
  • Logged In: NO

    testCustomConverterMapping needs to be extended to trigger
    this bug.

    1) ensure that the collection in the mapped to object is not
    null, eg.
    public Collection names = new ArrayList();

    2) add a list of Double in the back mapping from objp to
    TestCustomConverterObject as the converter only checks for
    the existence of a destination object in that case (note
    that that is quite valid as in the other direction the
    object is a Double)

    The result is that the destination will be the list rather
    than null and...
    java.lang.ClassCastException: java.util.ArrayList

     
    • status: open --> pending
     
  • Logged In: YES
    user_id=550744

    Nice catch. I have fixed and will be available in 1.5.6. I
    have attached the patched MappingProcessor.java.

    Thanks.

    Franz

     
    • status: pending --> closed