title: ModelMapper integration with Jooq Record
body: <p>===== <strong>POJO</strong> =====</p>
  
  <pre><code>// Employee POJO
       @JsonInclude(JsonInclude.Include.NON_NULL)
       @JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class)
       public class Employee implements Serializable {
         private Integer id;
         private String name;
         private Integer companyId;
         // assume getters ,setters and serializable implementations.
       }
  // Company POJO
       @JsonInclude(JsonInclude.Include.NON_NULL)
       @JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class)
       public class Company implements Serializable {
         private Integer id;
         private String name;
         // assume getters ,setters and serializable implementations.
       }
  
  // EmployeeVO POJO
       @JsonInclude(JsonInclude.Include.NON_NULL)
       @JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class)
       public class EmployeeVO implements Serializable {
         private Employee employee;
         private Company company;
  
         // assume getters ,setters and serializable implementations.
       }
  </code></pre>
  
  <p>===== <strong>My DAO layer class</strong> =====</p>
  
  <pre><code>public List&lt;EmployeeVO&gt; getEmployees(){     
      // configuring model mapper.
         ModelMapper modelMapper = new ModelMapper();
         modelMapper.getConfiguration()
                    .addValueReader(new RecordValueReader())
                .setSourceNameTokenizer(NameTokenizers.UNDERSCORE);
  
      //property map configuration.
        PropertyMap&lt;Record, EmployeeVO&gt; employeeVOMap = new PropertyMap&lt;Record, EmployeeVO&gt;() {
         protected void configure() {
            map().getEmployee().setName(this.&lt;String&gt;source("name"));
            map().getEmployee()..setId(this.&lt;Integer&gt;source("id"));
            map().getCompany().setName(this.&lt;String&gt;source("comp_name"));
            map().getCompany().setId(this.&lt;String&gt;source("comp_id"));
          }
       };
      // TypeMap config
      modelMapper.createTypeMap(Record.class, EmployeeVO.class);
      // adding employeeVOMap .
      modelMapper.addMappings(employeeVOMap);         
  
  // JOOQ query  
      List&lt;Field&lt;?&gt;&gt; fields = Lists.newArrayList();  
      //  fields includes, id, name, comp_name, comp_id
  
      SelectJoinStep query = select(dslContext, fields).from(EMPLOYEE)
                                         .join(COMPANY)
                                         .on(COMPANY.ID.equal(EMPLOYEE.COMPANY_ID));    
          Result&lt;Record&gt; records = query.fetch();
  
      Record record = null;
          Iterator&lt;Record&gt; it = records.iterator();
          List&lt;EmployeeVO&gt; employeeList=  Lists.newArrayList();
          while (it.hasNext()) {
              record = it.next();
  
              EmployeeVO employeeVOObj =
                      modelMapper.map(record, EmployeeVO.class);
              employeeList.add(employeeVOObj);
          }
      return employeeList;    
  }
  </code></pre>
  
  <p>===== <strong>Error log</strong> =====</p>
  
  <p>1) Error <code>mapping org.jooq.impl.RecordImpl to com.myportal.bingo.db.model.EmployeeVO</code>
      1 error] with root cause
      java.lang.ArrayIndexOutOfBoundsException: -1</p>
  
  <p><strong>Note:</strong> 
  ModelMapper throws the above exception when it reaches below method.<br></p>
  
  <p><code>private void matchSource(TypeInfo&lt;?&gt; sourceTypeInfo, Mutator destinationMutator)</code> 
  in <code>ImplicitMappingBuilder.java</code></p>
  
  <pre><code>sourceTypeInfo.getAccessors() is null.
  </code></pre>
  
  <p>Any help?</p>