As per the Dozer documentation the one-way fields are only mapped when "a" object is mapped to "b" object. If "b" is mapped to "a", then the field is not mapped.
But for the below code "b" is still getting mapped to "a".
<mapping >
<class-a>com.examples.source.Source</class-a>
<class-b>com.examples.destination.Destination</class-b>
<field type="one-way">
<a set-method="setIRCCode" get-method="getIRCCode">ircCode</a>
<b set-method="setIrcCode" get-method="getIrcCode">ircCode</b>
</field>
</mapping>
package com.examples.source;
public class Source {
protected String ircCode;
public String getIRCCode() {
return ircCode;
}
public void setIRCCode(String value) {
this.ircCode = value;
}
}
package com.examples.destination;
public class Destination {
private String ircCode;
public String getIrcCode() {
return this.ircCode;
}
public void setIrcCode(String ircCode) {
this.ircCode = ircCode;
}
}
public class Mapping {
public static void main(String[] args) {
DozerBeanMapper mapper = new DozerBeanMapper(Arrays.asList(new String[]{"Dozer-Mapping.xml"}));
Destination destinationObj=new Destination();
destinationObj.setIrcCode("B");
Source srcObj= mapper.map(destinationObj, Source.class);
System.out.println("Reverse Mapping IRCCode= "+ srcObj.getIRCCode());
}
}
Output when running the above code:
Reverse Mapping IRCCode= B **(Unexpected and Wrong Result)**
The expected result is :
Reverse Mapping IRCCode= null
I am using Dozer 5.4.0 version.