Menu

#369 Pojo Lists -> JAXB Lists, Generic Type Info is not used

Dozer v5.3.2
open
nobody
5
2012-03-20
2012-03-20
No

When mapping list fields from POJOs to list fields from JAXB Objects, the Type Info of the list is not used (using hints works fine).
The following Exception is logged:
"java.lang.NoSuchMethodException: Unable to determine write method for Field: '<fieldname>' in Class: class <Classname of JAXB Class>
at org.dozer.propertydescriptor.JavaBeanPropertyDescriptor.getWriteMethod(JavaBeanPropertyDescriptor.java:47)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.genericType(GetterSetterPropertyDescriptor.java:334)
at org.dozer.fieldmap.FieldMap.getGenericType(FieldMap.java:145)
"

org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.genericType tries to get the generic type via the setter method, which is not existent for lists in jaxb objects. I propose to change the Method to the following:
"
public Class<?> genericType() {
Class<?> genericType = null;
try {
Method method = getWriteMethod();
genericType = ReflectionUtils.determineGenericsType(method, false);
} catch (NoSuchMethodException e) {
try {
Method method = getReadMethod();
genericType = ReflectionUtils.determineGenericsType(method, true);
} catch (NoSuchMethodException e) {
log.warn("The destination object: {} does neither have a write nor read method for property : {}", e);
}
}

return genericType;
}
"

Discussion


Log in to post a comment.