Dependency used in Gradle:
compile group: 'org.modelmapper', name: 'modelmapper', version: '2.3.8'
Code
Currently I have:
modelMapper = new ModelMapper();
modelMapper.getConfiguration()
.setMatchingStrategy(MatchingStrategies.STANDARD)
.setFieldMatchingEnabled(true)
.setFieldAccessLevel(Configuration.AccessLevel.PRIVATE);
My entity has
@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Phones> phones = new ArrayList<>();
My second entity:
@ManyToOne
@JoinColumn(name = "employee_id")
private Employee employee;
My DTO which I want to have:
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class EmployeeDTO {
@Singular
private final List<PhoneDTO> phones;
}
I am mapping this in this way:
EmployeeDTO.EmployeeDTOBuilder employeeDTOBuilder =ObjectMapperUtils.map(employee, EmployeeDTO.employeeDTOBuilder.class);
Error
I'm getting this error:
1) Converter org.modelmapper.internal.converter.MergingCollectionConverter@969b4391 failed to convert org.hibernate.collection.internal.PersistentBag to java.util.ArrayList.
Question
How should ModelMapper configuration looks like?