1

我有以下课程。

// 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;
    }

执行上述代码时,我遇到了以下异常...

-------------------------------------------------- ------------ Unenhance strategy: ma.glasnost.orika.unenhance.BaseUnenhancer@3547efb7 -----结束当前状态的转储--------------- ---------------- 在 ma.glasnost.orika.impl.ExceptionUtility.newMappingException(ExceptionUtility.java:55) 测试 au.com.copl.dbaccesslayer.session.WebserviceBeanTest 失败

4

1 回答 1

2

看来这是一个 Orika 错误,我在这里报告了它:https ://github.com/orika-mapper/orika/issues/104 。

为映射器生成的字节码不正确,null先声明一个变量,然后尝试访问它。

于 2016-01-29T14:40:00.970 回答