Reputation: 1147
I have the following classes.
// Source Classes
class SourceEmployer
{
private EmployerDetail employerDetail;
// getters/setters
}
class EmployerDetail
{
private String name;
// getters/setters
}
// Destination Classes
class DestApplication
{
private Employment employment;
// getters/setters
}
class Employment
{
private Set<EmployerDetails> employerDetails;
// getters/setters
}
class EmployerDetails
{
private String employerName;
// getters/setters
}
// Some Mapping configuration
public DestApplication getOrikaMapping(SourceEmployer source, DestApplication destination)
{
MapperFacade mapper;
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
mapperFactory.classMap(source.getClass(), destination.getClass())
.field("employerDetail.name",
"employment.employerDetails{employerName}")
.byDefault()
.register();
mapper = mapperFactory.getMapperFacade();
DestApplication dto = mapper.map(source, DestApplication.class);
return dto;
}
When Execute the above code I have faced the exception below...
------------------------------------------------------------- Unenhance strategy: ma.glasnost.orika.unenhance.BaseUnenhancer@3547efb7 -----end dump of current state------------------------------- at ma.glasnost.orika.impl.ExceptionUtility.newMappingException(ExceptionUtility.java:55) Test au.com.copl.dbaccesslayer.session.WebserviceBeanTest FAILED
Upvotes: 1
Views: 1298
Reputation: 9945
It seems it's an Orika bug, I reported it here: https://github.com/orika-mapper/orika/issues/104.
The bytecode generated for the mapper is incorrect and declares a null
variable first and then tries to access it.
Upvotes: 2