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
10
votes
1 answer

Is it good to upgrade to MapStruct from ModelMapper?

Currently we are using ModelMapper in our project. However in the site i see there are lot of likes for MapStruct. Not sure the differences and whether we need to really go for an upgrade. What are the differences between ModelMapper and MapStruct…
Java Architect
  • 201
  • 3
  • 5
10
votes
5 answers

How to map a DTO to an existing JPA entity?

I'm trying to map a Java DTO object to an existing JPA entity object without having to do something like the following: public MyEntity mapToMyEntity(SomeDTO dto, MyEntity entity) { entity.setField1(dto.getField1()); …
dyslexit
  • 689
  • 1
  • 9
  • 18
10
votes
2 answers

ModelMapper get confuse on different properties

I have a Student object extending Person object. public abstract class Person implements IIdentifiable { private String contactNumber; // other properties public String getContactNumber() { return contactNumber; } …
Susitha Ravinda Senarath
  • 1,648
  • 2
  • 27
  • 49
9
votes
1 answer

ModelMapper with Spring, where to put explicit mappings?

I'm using ModelMapper with Spring. In my controller class I'm autowiring the ModelMapper bean: @Autowired private ModelMapper mapper; I want to do an explicit mapping between my model class and my DTO in my controller methods, something…
italktothewind
  • 1,950
  • 2
  • 28
  • 55
9
votes
4 answers

ModelMapper - Failed to instantiate instance of destination

I'm working with mongodb so I'm decoupling entities from presentation layer creating DTOs (with hibernate-validator annotations). public abstract class UserDTO { private String id; @NotNull protected String firstName; …
anat0lius
  • 2,145
  • 6
  • 33
  • 60
8
votes
3 answers

modelmapper null value skip

Class A { private String a; private String b; private B innerObject; } Class B { private String c; } In my case, String b might come in with a null value. My modelmapper configuration is like below: ModelMapper mapper = new…
AchuSai
  • 93
  • 1
  • 1
  • 6
8
votes
3 answers

ModelMapper: mapping abstract classes during runtime

I am using ModelMapper Framework (http://modelmapper.org/) for mapping objects in Java. I have encountered a problem while mapping concrete classes (DTO to Entites) containing abstract classes. Example: Task has a list of AbstractItems.…
kk-dev11
  • 2,654
  • 5
  • 37
  • 48
7
votes
1 answer

ModelMapper - failed to convert org.hibernate.collection.internal.PersistentBag to java.util.ArrayList

How should ModelMapper configuration looks like? compile group: 'org.modelmapper', name: 'modelmapper', version: '2.3.8' Currently I have: modelMapper = new ModelMapper(); modelMapper.getConfiguration() …
Shirabu
  • 99
  • 1
  • 4
7
votes
0 answers

How to use generics in modelmapper converter

I am trying to use a Converter to specify the mapping of a simple String field in a DTO to a TypedString-Object which is part of another complex Object. The problem is, that TypedString is an Interface for several implementations. Such a converter…
7
votes
3 answers

ModelMapper converter - not working

I'm using ModelMapper in my rest apps. I have to convert List to List. This is my code: Converter,List> listConverter = new Converter, List>() { public List
insectoman
  • 73
  • 1
  • 1
  • 5
7
votes
1 answer

Modelmapper: How to apply custom mapping when source object is null?

Lets assume I have class MySource: public class MySource { public String fieldA; public String fieldB; public MySource(String A, String B) { this.fieldA = A; this.fieldB = B; } } and I would like to translate it to…
Tinki
  • 1,486
  • 1
  • 21
  • 32
6
votes
1 answer

converting entities into model in clean architecture in dart

As in clean architecture, we have to define the Entities in Domain layer and Models in Data layer. Now the issue that i am facing is in converting the entities into models when we are passing that as a request object in repositories. here is the…
Hunt
  • 8,215
  • 28
  • 116
  • 256
6
votes
3 answers

Lazy Initialization Exception in model mapper

Modelmapper is giving LazyInitializationException while converting from entity to dto. Is there any way i can disable this. If am calling modelmapper.map inside transaction block it is working fine but it is loading all my lazy objects which i dont…
Nayak
  • 99
  • 1
  • 7
6
votes
1 answer

ModelMapper returns NULL when trying to map Entity to DTO object

Here is the class of the object I am trying to map: package com.agent.module.entities; import java.util.Set; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import…
Stefan Radonjic
  • 1,449
  • 4
  • 19
  • 38
6
votes
1 answer

ModelMapper - Converter/ AbstractConverter vs Provider

I'm using ModelMapper to convert some objects to complex DTOs and vice-versa. Even though I've tried to understand the documentation, I've found hard to understand when to use a Converter or a Provider or an AbstractConverter. Now, for example, if I…
magnoz
  • 1,939
  • 5
  • 22
  • 42
1
2
3
28 29