未能将org.hibernate.collection.internal.persistentbag转换为java.util.arraylist

nzkunb0c  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(383)

modelmapper配置应该是什么样子?
编译组:“org.modelmapper”,名称:“modelmapper”,版本:“2.3.8”
目前我有:

modelMapper = new ModelMapper();
            modelMapper.getConfiguration()
                    .setMatchingStrategy(MatchingStrategies.STANDARD)
                    .setFieldMatchingEnabled(true)
                    .setFieldAccessLevel(Configuration.AccessLevel.PRIVATE);

我的实体

@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Phones> phones = new ArrayList<>();

我的第二个实体:

@ManyToOne
@JoinColumn(name = "employee_id")
private Employee employee;

我想要的数据:

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class EmployeeDTO {

@Singular
private final List<PhoneDTO> phones;

}

我以这种方式绘制:

EmployeeDTO.EmployeeDTOBuilder employeeDTOBuilder 
= ObjectMapperUtils.map(employee, EmployeeDTO.employeeDTOBuilder.class);

我得到:
转换器org.modelmapper.internal.converter。mergingcollectionconverter@969b4391 无法将org.hibernate.collection.internal.persistentbag转换为java.util.arraylist。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题