我有以下课程。
// 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;
}
当执行上面的代码时,我遇到了以下例外......
----------------------------------------------- --------------不加强策略: ma.glasnost.orika.unenhance.BaseUnenhancer@3547efb7 -----最终转储当前状态------------------------------- at ma.glasnost.orika.impl。 ExceptionUtility.newMappingException(ExceptionUtility.java:55) 测试au.com.copl.dbaccesslayer.session.WebserviceBeanTest FAILED
答案 0 :(得分:2)
它似乎是一个Orika bug,我在这里报告:https://github.com/orika-mapper/orika/issues/104。
为映射器生成的字节码不正确,首先声明null
变量,然后尝试访问它。