Menu

Multiple bean mapping

Help
Daniel
2013-12-04
2013-12-05
  • Daniel

    Daniel - 2013-12-04

    Hi,

    using SuperCSV is a great help to me. But I came across a problem mapping multiple beans. I got a csv file, containing information for multiple beans (per line). But as I can see from your examples it is only possible to map each line into one bean (not into two or more beans).

    Is there a way of doing this, i.e. creating a new bean, containing the all beans I need and do a deep mapping:

    class MultiBeanWrapper {
    
        Address addreass;
        BankAccount bankAccount;
    
    }
    
    ...
    String[] FIELD_MAPPING = new String[] 
             {address.street, bankAccount.bankNumber};
    ...
    beanReader.read(MultiBeanWrapper.class, processors));
    

    I did not try this, because I want to be sure there is no other way.

    Thanks for your help and best regards
    Bart

     

    Last edit: Daniel 2013-12-04
  • James Bassett

    James Bassett - 2013-12-05

    See answer on StackOverflow