【发布时间】:2020-05-08 11:13:59
【问题描述】:
我有如下目标实体:
public class ApplicationUsage {
@Id
private ApplicationUsagePK appUsage; //Guid No documentation available.
private String name;
.
.
public ApplicationUsage(String id, Integer compId) {
this.appUsage = new ApplicationUsagePK(id, compId); //This is present in ApplicationUsagePK initiated here which acts are composite key
}
源对象如下:
public class ApplicationUsage {
@SerializedName("id")
@Expose
private String id;
@SerializedName("name")
@Expose
private String name;
我需要将源对象的 ID 映射到 applicationUsage(String id 并且 CompID 来自其他变量,它需要映射到 applicationUsage(.., Integer compId) em>
上述类或映射器需要进行哪些更改才能实现相同的效果?
以下是当前映射器:
@Mapper
public interface ApplicationUsageMapper {
ApplicationUsageMapper MAPPER = Mappers.getMapper( ApplicationUsageMapper.class );
ApplicationUsage entityToDao(com.inte.meow.vo.computer.ApplicationUsage source);
}
不好的方式:
我使用了不好的方法来解决这个问题,你可以理解以下内容:
ApplicationUsage aUsage = ApplicationUsageMapper.MAPPER.entityToDao(agreement.getBody());
aUsage.initiateApplicationUsage(agreement.getBody().getId(), compId);
【问题讨论】: