I have an xml mapping defined:
<mapping>
<class-a>java.util.HashMap</class-a>
<class-b>com.example.MyClass</class-b>
<field>
<a key="myDateField">this</a>
<b>myXMLGregorianCalendarField</b>
</field>
</mapping>
Here value for key myDateField
contains instance of java.lang.Date class
.
Field com.example.MyClass#myXMLGregorianCalendarField
expects instance of javax.xml.datatype.XMLGregorianCalendar
.
This mapping always throws an exception:
MapId: null
Type: null
Source parent class: java.util.HashMap
Source field name: this
Source field type: class java.util.Date
Source field value: Thu Jan 01 03:00:00 MSK 1970
Dest parent class: com.example.MyClass
Dest field name: myXMLGregorianCalendarField
Dest field type: javax.xml.datatype.XMLGregorianCalendar
org.dozer.MappingException: Illegal object type for the method 'setMyXMLGregorianCalendarField'.
Expected types:
javax.xml.datatype.XMLGregorianCalendar
Actual types:
java.util.Date
How to make this conversion work properly?
Note Long-long debugging revealed that primitive converters are called differently for maps and "non-maps". So here comes the second question: why?