title: Reading nested POJO with super-CSV
body: <p>I was trying to load a nested POJO with CSV . For some error I couldnt make it work.</p>
  
  <p>Please find my code below. The below class Person contains two POJO field address and attribs</p>
  
  <pre><code>public class Person
  {
      public String          firstname;
      public String          lastname;
      public PersonAttribute attribs;
      public Address         address;
      //Getters and setters
  }
  
  
  PersonAttribute class 
  
  {
     public int height;
     public int weight;
     //Getters and setters
  }
  </code></pre>
  
  <p>Address class</p>
  
  <pre><code>public class Address
  {
     public String      city;
     public String      zipCode;
     public GeoLocation geoLocation;
  </code></pre>
  
  <p>//Getters and setters
      }</p>
  
  <p>GeoLocation</p>
  
  <pre><code>public class GeoLocation
  {
      private String latitude;
      private String longitude;
  </code></pre>
  
  <p>//Getters and setters
      }</p>
  
  <p>And now I am trying to read the CSV and populate person class . I am not able to make it work. Here is my code</p>
  
  <pre><code>public class ReadWithCsvDozerBeanReader
  {
  
      private static final String        CSV                      = "firstname, lastname, height, weight, city,zipcode,latitude,longitude\n"
          + "bill,smith,180,200,ABC,123,48.8525525,2.3417763\n" + "james,smith,192,250,DEF,456,48.852129,2.3355093";
  
      private static final int           ATT_START_INDEX          = 2;
  
      private static final int           ADDRESS_START_INDEX      = 4;
  
      private static final int           GEO_LOCATION_START_INDEX = 6;
  
      // custom preferences required because CSV contains spaces that aren't part
      // of the data
      private static final CsvPreference PREFS                    = new CsvPreference.Builder(
              CsvPreference.STANDARD_PREFERENCE).surroundingSpacesNeedQuotes(true).build();
  
      public static void main (String[] args) throws IOException
      {
          readWithCsvDozerBeanReader(new StringReader(CSV));
  
      }
  
      private static void readWithCsvDozerBeanReader (final Reader reader) throws IOException
      {
          ICsvDozerBeanReader beanReader = null;
          try
          {
              beanReader = new CsvDozerBeanReader(reader, PREFS);
  
              final String[] header = beanReader.getHeader(true);
  
              // set up the field mapping, processors and hints dynamically
              final String[] fieldMapping = new String[header.length];
              final CellProcessor[] processors = new CellProcessor[header.length];
              final Class&lt;?&gt;[] hintTypes = new Class&lt;?&gt;[header.length];
              for (int i = 0; i &lt; header.length; i++)
              {
                  if (i &lt; ATT_START_INDEX)
                  {
                      // normal mappings
                      fieldMapping[i] = header[i];
                      processors[i] = new NotNull();
                      hintTypes[i] = Person.class;
                  }
                  else if (i &lt; ADDRESS_START_INDEX)
                  {
                      // attribute mappings
                      fieldMapping[i] = header[i];
                      processors[i] = new NotNull();
                      hintTypes[i] = PersonAttribute.class;
                  }
                  else if (i &lt; GEO_LOCATION_START_INDEX)
                  {
  
                      // Address mappings
                      fieldMapping[i] = header[i];
                      hintTypes[i] = Address.class;
  
                  }
                  else
                  {
                      fieldMapping[i] = header[i];
                      hintTypes[i] = GeoLocation.class;
                  }
  
              }
  
              beanReader.configureBeanMapping(Person.class, fieldMapping, hintTypes);
  
              Person person;
              while ((person = beanReader.read(Person.class, processors)) != null)
              {
                  System.out.println(String.format("lineNo=%s, rowNo=%s, person=%s", beanReader.getLineNumber(),
                          beanReader.getRowNumber(), person));
              }
  
          }
          finally
          {
              if (beanReader != null)
              {
                  beanReader.close();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>I am getting the below error
      Exception in thread "main" org.dozer.MappingException: No read or write method found for field (height) in class</p>