hi,
In recent development, I found dozer is not very convenient. My requirement described below:
query string (request.getParameterMap) --> DTO --> Domain Object.
1. Attribute names in DTO must as same as query param. For example,
query string:
?payment_code=12345678
DTO:
private String payment_code
2. if the Domain Object's attribute name is inconsistent with DTO's,eg.
Domain Object:
private String orderId;
So in this situation, you can't simply using @Mapping("orderId") in DTO for converting DTO to Domain Object successfully.Because if you do so, it will throw exception like this when you convert query params to DTO:
org.dozer.MappingException: No such field found java.util.HashMap.orderId
So after several unsuccessful attempts, finally I found a solution.
That is supply addtional getter/setter method in DTO, for example:
DTO
private String payment_code;
//getter and setter for payment_code here
//addtional getter and setter for successully converting to Domain Object
public String getOrderId(){return paymnet_code;}
public void setOrderId(){}
Now query params --> DTO ok, and DTO-->Domain Object ok too.
But you know there are many params not only payment_code(e.g. service_id, user_id,credit_name,creadit_amount and so on), so iot's terrible to add so many addtional getter/setter methods.
Apart from above, value of request.getParameterMap is string array, not string, so at first I have to covert this Map to common hashmap.
So can optimise dozer for this situation?