Does StatefulBeanToCsv work for child classes that extend other?

Joined
Nov 29, 2017
Messages
1
Reaction score
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top