Does StatefulBeanToCsv work for child classes that extend other?

Discussion in 'Java' started by N3kt4R, Nov 29, 2017.

  1. N3kt4R

    N3kt4R

    Joined:
    Nov 29, 2017
    Messages:
    1
    Likes Received:
    0
    I want to export an entity class to csv, but when I use the below code, I manage to export only the fields of the child class while the parent's attributes are missing. Is there any restriction? I use opencsv 4.1.

    ColumnPositionMappingStrategy<MyEntity> mappingStrategy = new ColumnPositionMappingStrategy<MyEntity>();
    // Set mappingStrategy type to MyEntity
    mappingStrategy.setType(MyEntity.class);

    StatefulBeanToCsvBuilder<MyEntity> builder = new StatefulBeanToCsvBuilder<ActiveSubstance>(writer);

    StatefulBeanToCsv<MyEntity> beanWriter = builder.withMappingStrategy(mappingStrategy).build();
    // Writing data to csv file
    beanWriter.write(entries);
    writer.close();

    Could you please help me?
    Thank you in advance.
     
    N3kt4R, Nov 29, 2017
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.