i have hibernate criteria with specific projection list:
criteria.setProjection(Projections.projectionList()
.add(Projections.property("contract.autoId"), "contractId")
.add(Projections.property("customer.firstName"), "firstName")
.add(Projections.property("contract.startDate"), "startDate")
.add(Projections.property("contract.endDate"), "endDate"));
I want to map the response of this criteria to the following DTO object:
public class Contract {
private int contractId;
private String description;
private Date startDate;
private Date endDate;
}
The types of response for this criteria:
So, first object has Long type, but in DTO contractId has int type.I don't have permission to change this dto object.
So, when i added ResultTransformer to my criteria:
criteria.setResultTransformer(Transformers.aliasToBean(Contract.class));
I got following exception:
java.lang.IllegalArgumentException: argument type mismatch
Is it possible to say to Transformers.aliasToBean to convert automatically value from Long type to int?