I am facing a very strange behavior in Java, I get two different classes that do not have a hierarchical connection : Class templates (type hierarchy object -> a -> b -> template), and square template deto (object -> template dto).
I for model mapping (Org.modelmapper.ModelMapper) for mapping between two classes (which uses the same mapping from field names).
The following is the code:
List & lt; Template & gt; Templates = cvService.getTemplates (); & Lt; TemplateDto & gt; Results = New Arrestist & gt; TemplatesDo & gt; (); ModelMapper.map (templates, resultDtos); TemplateDto Example = Results Dtos.get (0);
and throws the last row:
java.lang.ClassCastException: com.vs.framework.domain.cv.Template should not be included in the comm can. Vs.framework.dto.cv.TemplateDto
This is very strange. When I want to debug this segment, after the mapping, the result is that instead of the list there is a list of inventory list which blows my brain.
I have tried to clean my tomatoes, but it is still clear.
Any ideas?
Java ArrayList
a ArrayList & gt; TemplateDto & gt;
is considered.
To get this problem with the list, to use a TypeToken
, this should look something like this:
list & lt; Templates & gt; Templates = cvService.getTemplates (); Type list type = new typography & lt; List & gt; TemplatesDown & gt; & Gt; () {} .getType (); & Lt; TemplateDto & gt; ResultDtos = modelMapper.map (templates, list type); TemplateDto Example = Results Dtos.get (0);
No comments:
Post a Comment