Again I found something. I would call it a bug, because it doesnt work with my usecase:
I think the whole map-get-method-thing isnt meant to be the way I want. Today I wanted to use the nice date-format attribute with a german date string:
<a map-get-method="getColByName" key="fieldNameA" date-format="dd.MM.yyyy">this</a>
This didnt work, because all the nice things which were added to dozer like the date-format attribute were thought for the simple way of getting a value from the source object. In combination with map-get-method it is simply ignored.
As I browsed through the code i noticed that all the different features are not developed in a hierarchical way. There must be something like getRealValueFromSourceObject() and something like processRealValue() which must be called afterwards (in every case). Unfortunatly the value-getting and the value-processing tasks are mixed, so I might get some more problems in the future. :(
So again here is my patch, hope someone will benefit from this.
with Dozer version 3.4,
in function mapOrRecurseObject,
at line 435,
//instead of directly returning the result,
//check if next condition will be true.
//If it is, the result will be the source
//which will get wrapped through the //primitiveOrWrapperConverter
Object result = mapCustomMapToProperty(sourceFieldValue, sourceFieldClass, fieldMap, destObj, destFieldType);
if (!MappingUtils.isPrimitiveOrWrapper(sourceFieldClass) && !MappingUtils.isPrimitiveOrWrapper(destFieldType))
sourceFieldValue = result;
One thing to say: I still appreciate all the work that has been done and im still happy with dozer. But you may should think about a refactoring. Ok, I dont have the time to do that either :)
Thanks so far!
Log in to post a comment.