gpt4 book ai didi

java - Orika - 将对象(源)映射到对象(目标)的集合(集合)

转载 作者:行者123 更新时间:2023-11-30 03:04:42 26 4
gpt4 key购买 nike

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

当执行上面的代码时,我遇到了下面的异常...

------------------------------------------------------------- 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

最佳答案

看来是 Orika 的 bug,我在这里报告了:https://github.com/orika-mapper/orika/issues/104 .

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

关于java - Orika - 将对象(源)映射到对象(目标)的集合(集合),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35084727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com