Closed heloufir closed 6 years ago
@garethahealy can you please take a look to this issue.
@eloufirhatim ; i've not had much free time recently to work on dozer issues. But if you create a github repo with an example showing the problem, it makes it easier to debug/check what you are trying to do.
@garethahealy Sorry for bothering you, unfertunotely the project is big and it's private, so I can't push it into a github repository, but I can give you all the information that you wan't when you have some free time. Thanks again
@eloufirhatim ; can you slim it down? it can map fake data/doesn't have to involve the web bits you mentioned. but i need a reproducible bit of code to look at which fails 100% (or as near as possible)
@garethahealy Okay, I'll see how I can prepare a scenario to get you as close as possible to the error. Thanks a lot
I just got it working by changing a lit bit in my mapping xml file.
I changed my mappings from:
<mapping map-id="MAPPING_HAB_USER" map-empty-string="false"
map-null="false" wildcard="false">
<class-a>com.intranet.si.model.habilitation.User</class-a>
<class-b>com.intranet.si.dto.habilitation.UserDTO</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
<field>
<a>userName</a>
<b>userName</b>
</field>
<field>
<a>isOnline</a>
<b>isOnline</b>
</field>
<field map-id="MAPPING_USER_EMPLOYEE">
<a>refEmployee</a>
<b>refEmployee</b>
</field>
</mapping>
With the MAPPING_USER_EMPLOYEE
<mapping map-id="MAPPING_USER_EMPLOYEE" map-empty-string="false"
map-null="false" wildcard="false">
<class-a>com.intranet.si.model.hr.Employee</class-a>
<class-b>com.intranet.si.dto.hr.EmployeeDTO</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
<field>
<a>firstName</a>
<b>firstName</b>
</field>
<field>
<a>lastName</a>
<b>lastName</b>
</field>
</mapping>
To this signle mapping
<mapping map-id="MAPPING_HAB_USER" map-empty-string="false"
map-null="false" wildcard="false">
<class-a>com.intranet.si.model.habilitation.User</class-a>
<class-b>com.intranet.si.dto.habilitation.UserDTO</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
<field>
<a>userName</a>
<b>userName</b>
</field>
<field>
<a>isOnline</a>
<b>isOnline</b>
</field>
<field>
<a>refEmployee.id</a>
<b>refEmployee.id</b>
</field>
<field>
<a>refEmployee.firstName</a>
<b>refEmployee.firstName</b>
</field>
<field>
<a>refEmployee.lastName</a>
<b>refEmployee.lastName</b>
</field>
</mapping>
I used to use this option Context Based Mapping like said in the DozerMapper GitBook, but in some cases this mapping is broken, for exemple if I launch the application directly in the Employee view it's working without any error, but if I go to another view (a specific one) and return to the Employee view, here the mapping is borken, and instead of getting only id, firstName and lastName of the refEmployee of the user, I got all the columns, references, list, ... of the refEmployee object.
So the issue is gone when I specify directly the value that I want in the first mapping without using any other mapping in it.
If possible that you explain to me, if I did something wrong.
Thank you for your help.
Runtime
Project details
I am developping a project based on SpringBoot and Hibernate, using DozerMapper/dozer repository.
Problem
Steps to reproduce:
I have had this same error when I was using the net.sf.dozer repository, after I switched to this repository (DozerMapper/dozer) for a while I get the error fixed, but now it's back
Please I need help