0
votes

So I have a method that needs to convert a bean to a CSV file and for this purpose, I am using OpenCsv. But for some reason, it's not showing ids from the nested beans.

Here is my root bean

public class Person {

    @CsvIgnore
    private long id;

    @CsvIgnore
    private String firstName;

    @CsvBindByName
    private String email;

    @CsvIgnore
    Date dob;

    @CsvRecurse
    List<Address> addresses;
}

And nested bean

public class Address {

   @CsvBindByName
   private long id;

   @CsvIgnore
   private String addressLine;
}

Expected CSV file where to be shown only the user's email and his addresses ids

[email protected], 1, 2, 3, 4
[email protected], 10, 22, 33, 44