Menu

#39 Reading into lists of beans with indexed mapping doesn't work

2.1.0
closed
None
5
2013-04-29
2013-04-23
No

CsvDozerBeanReader can read into Lists of Strings using indexed mapping, but when you combine it with a cell processor (that creates a bean or Integer/Date etc) and use indexed mapping to read into a List it doesn't work.

This was discovered while trying to answer this StackOverflow question, in which a Person has a List of PersonAttributes. A custom cell processor created a PersonAttribute, and indexed mapping was used (e.g. attribs[0]) to map the attribute to the List of attributes in the Person. Dozer didn't map it correctly and each element in the attribute List was actually an empty List (not a PersonAttribute!!).

Curiously, when using no custom cell processor and using deep+indexed mapping (attribs[0].value) Dozer was able to map everything correctly.

Discussion

  • James Bassett

    James Bassett - 2013-04-24
    • status: open --> pending
     
  • James Bassett

    James Bassett - 2013-04-24

    It appears that Dozer needs a hint when doing this kind of mapping, so I've updated configureBeanMapping() to allow hint types to be specified.
    [r283]

     

    Related

    Commit: [r283]

  • James Bassett

    James Bassett - 2013-04-24
    • Status: pending --> closed
     
  • James Bassett

    James Bassett - 2013-04-29
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -CsvDozerBeanReader can read into Lists of standard Java types (Lists of Strings, Integers, etc) using indexed mapping, but when you combine it with a cell processor (that creates a bean) and use indexed mapping to read into a List of beans it doesn't work.
    +CsvDozerBeanReader can read into Lists of Strings using indexed mapping, but when you combine it with a cell processor (that creates a bean or Integer/Date etc) and use indexed mapping to read into a List it doesn't work.
    
     This was discovered while trying to answer [this](http://stackoverflow.com/q/16111296/1068649) StackOverflow question, in which a `Person` has a List of `PersonAttributes`. A custom cell processor created a `PersonAttribute`, and indexed mapping was used (e.g. `attribs[0]`) to map the attribute to the List of attributes in the Person. Dozer didn't map it correctly and each element in the attribute List was actually an empty List (not a `PersonAttribute`!!).
    
     

Log in to post a comment.

MongoDB Logo MongoDB