Questions tagged [modelmapper]

An intelligent object mapping framework that automatically maps objects to each other.

ModelMapper is an intelligent object mapping framework that automatically maps objects to each other. It uses a convention based approach to map objects while providing a simple refactoring safe API for handling specific use cases.

435 questions
4
votes
2 answers

How to read a Java class method annotation value with ASM

How can I read read the value of a Java method annotation at runtime with ASM ? The Annotation has only a CLASS RetentionPolicy, so it's not possible to do that with Reflections. | Policy CLASS: Annotations are to be recorded in the class file by…
Tobse
  • 1,176
  • 1
  • 9
  • 22
4
votes
1 answer

ModelMapper produces exception while converting Entity to DTO

I am trying to convert Entities to DTOs, which are used in a Rest service. My Entity is the below: @Entity @Table(name = "USERS") public class User extends AbstractEntity { @Column(name = "LOGIN") private String login; @Column(name =…
sissythem
  • 751
  • 1
  • 8
  • 25
4
votes
0 answers

Java ModelMapper multiple-level nested collection mapping override (with and without lambda expressions)

I am maintaining a tree of some sort. The generic tree node has this form: public class Node { private String s; private ReadWriteLock sLock; //read on. private List descendants; private ReadWriteLock descLock; //read…
Kurobara
  • 161
  • 2
  • 12
4
votes
1 answer

Mapping a hardcoded value with ModelMapper

I'm evaluating the ModelMapper library to map a project DTOs and Entities. Although the library is quite powerful, I could not find a way to map a hardcoded value from on Entity to its DTO representation. The ModelMapper, maps a method from source…
Marcio Jasinski
  • 1,439
  • 16
  • 22
4
votes
1 answer

modelmapper skip nested object's properties

class A { class ADto { int id; -> int id; List b; List b; } } class B { class BDto { int id; -> int id; C c; CDto…
Divs
  • 1,578
  • 2
  • 24
  • 51
4
votes
1 answer

Modelmapper: Map an element in a list to field in POJO

public class SimpleDTO{ private String firstElement; private String lastElement; } public class ComplexSource{ private List elementList; } I tried to map it usingmap().setFirstElement(source.getElementList().get(0)) but I get…
Matrix
  • 67
  • 1
  • 6
4
votes
2 answers

How to skip a field during map stage?

I'm having list of employee objects - List I need to convert it into list of employee transfer objects - List Assume a field "password" exist in both the classes. In few cases i need the password needs to be included from Employee → EmployeeDTO In…
user2323036
  • 1,515
  • 5
  • 19
  • 27
4
votes
1 answer

Making JPA and ModelMapper work in entity updates

In my crud controller, the following is happening during Update operation Client does a request to "POST /{id}" and sends me a DTO inside request body. Then I call ModelMapper to convert the DTO into a database entity. After that, I set the Id field…
Can
  • 377
  • 2
  • 10
4
votes
3 answers

ModelMapper: Mix implicit and explicit mapping?

In order to write the minimum amount of code required, I'm trying to let ModelMapper generate its implicit mapping and only write explicit property mappings for those properties that it couldn't auto-map. If I let ModelMapper generate an implicit…
netmikey
  • 2,422
  • 2
  • 28
  • 35
3
votes
2 answers

Cascading PropertyMaps with ModelMapper

Consider 6 POJO classes: 3 DAOs and 3 DTOs. DAOs: "A", "B", "C" DTOs: "One", "Two", "Three" public class A { private int idOfA; private String name; private List b; // getters, setters, etc... } public class B { …
xelamitchell
  • 522
  • 1
  • 6
  • 18
3
votes
1 answer

Modelmapper.map Takes Very Long Time to Convert from DTO to Entity

Currently, modelMapper.map to convert from DTO to entity and the other way around takes approximately 3 s. Is that normal? Currently, this entity has 12 variables that are using ManyToOne relation. Previously, it takes 5 s for a single map. But…
Rilos
  • 31
  • 2
3
votes
2 answers

Model Mapper - using custom methods

A springboot project where I need to construct a DTO for a dashboard view using nominated fields from the parent and nominated fields from the newest of each of the children. The entities are Plane which has a OneToMany relationship with…
Al Grant
  • 2,102
  • 1
  • 26
  • 49
3
votes
1 answer

How to fix Error START_ARRAY token when deserializing Json with ModelMapper?

I'm trying to deserialize a JSON file in this format: [ ["AA", "GG", "1992/11/18"], ["BB", "DD", "2005/02/20"] ] Using this class: public class DataList { private List att; // constructor, getter and setter } doing: DataList []…
jimmy
  • 457
  • 5
  • 20
3
votes
1 answer

ModelMapper 2.4.4 and Groovy 3.0 compatibility issue

When switching from Groovy 2 to Groovy 3, ModelMapper 2.4.4 seems to now be failing to convert objects. ModelMapper itself does not throw an error, but rather just returns an object whose metaClass is still the initial class rather than the new…
3
votes
3 answers

Spring Boot Java map Entity to DTO: array literal (strings) INSTEAD of array of objects

sample get request: http://localhost:3000/contact/1 What I got: { "id": 1, "firstname": "First Name", "lastname": "Last Name", "emailaddresses": [ { "emailaddress": "email@gmail.com" }, { "emailaddress": "email@g.c" …
xyzit
  • 89
  • 1
  • 8