我有以下课程。
// 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
-----当前状态的结束转储-----------------------------------,位于ma.glasnost.orika.impl。 ExceptionUtility.newMappingException(ExceptionUtility.java:55)
测试au.com.copl.dbaccesslayer.session.WebserviceBeanTest失败
最佳答案
看来这是Orika错误,我在这里报告了它:https://github.com/orika-mapper/orika/issues/104。
为映射器生成的字节码不正确,并且先声明了一个null
变量,然后尝试访问它。