Menu

#149 Null Pointer Exception mapping to Collection Element

open
None
5
2009-10-23
2008-08-18
srinivas p
No

we gettting NullPointerException while mapping a domain object to XML Bean Array compiled for Java 1.5.
The mapping is working fine while converting from XML Bean to domain object.
The opposite i.e; Domain to XML bean does not work.

I created the domain bean EmployeeDet similar to the xml bean. As mentioned below the mappings work only if we add a element to list.

I think Dozer is unable to initialize the List before setting the value.

----------------------------------
Class
----------------------------------

class EmployeeDet {
ArrayList store=new ArrayList();
java.util.List<some.domain.Employee> getEmployeeList(){
final class EmployeeList extends java.util.AbstractList<some.domain.Employee> {
void put(int i, Object o){}
void add(int i, Object o){}
void remove(int i){ }

}
EmployeeList list=new EmployeeList();

return list;
}

}

----------------------------------
Mapping
----------------------------------
<mapping>
<class-a>some.domain.Employee</class-a>
<class-b>some.domain.EmployeeDet</class-b>
<field>
<a>firstName</a>
<b>EmployeeList[0].name</b>
</field>
</mapping>

Discussion

  • Nathan Deckard

    Nathan Deckard - 2008-09-30

    bump

     
  • dmitry (lv)

    dmitry (lv) - 2008-10-23

    If you could just create a unit test and attach that to the issue this problem will be next on my fix list :)

     
  • dmitry (lv)

    dmitry (lv) - 2009-10-23
    • assigned_to: nobody --> vadeg
     
  • Vadim Shaigorodskiy

    Could you attach xml schema for your XMl Bean, please?

     

Log in to post a comment.

MongoDB Logo MongoDB