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
2
votes
2 answers

Failed to instantiate instance of destination [subclassDTO]. Ensure that [subclassDTO] has a non-private no-argument constructor

Im working on a Springboot App exposing some endpoints that do not return the original Entities but they return their DTO. To map all the entities i am working using "org.modelmapper" version: 0.7.4 and project lombok to avoid implement getters,…
Agustin Miani
  • 31
  • 1
  • 4
2
votes
2 answers

ModelMapper: How to map to a List of generic instances of known concrete type

I want to convert with the ModelMapper a List<> to a List knowing the exact java.lang.Class of T. But the ModelMapper keeps only instantiating the common parent class of T... for your context: I want to convert a list of DTO to a list of Domain,…
Bill
  • 143
  • 1
  • 10
2
votes
3 answers

ModelMapping a Stream without a Lambda Expression

I'm not Java developer, but I have many years of experience in C#. I have a List that I need to convert to a List using ModelMapper where Foo and Bar have essentially identical properties. Currently I've written this as: @AutoWired…
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
2
votes
0 answers

Mapping abstract class by ModelMapper

I have such a simple class structure which has abstract classes and subclasses. I want them to be mapped to destination class structure using ModelMapper. I have checked and none of the solutions in other questions related to mapping abstract…
zolv
  • 1,720
  • 2
  • 19
  • 36
2
votes
2 answers

How to reach destination object in ModelMapper's AbstractConverter.convert() method

I would like to map fields from source into the existing object dest via custom Converter. Could you please suggest a canonical way to reach out dest object from AbstractConverter#convert() Please find the code below: Source source = new…
Dzmitry Bahdanovich
  • 1,735
  • 2
  • 17
  • 34
2
votes
1 answer

ModelMapper: Error mapping ID field from DTO to the ID field on the Entity

I am trying to Map from a ProductReviewDTO which has an int product ID to link to the Product found on the ProductReview entity. However using ModelMapper it can't seem to map correctly. Resulting in a failed to set value error message as well as an…
JamieH9004
  • 21
  • 1
2
votes
1 answer

SOAP Request Mapping using ModelMapper

I am trying to map a SOAP request to a Java POJO using org.modelmapper.ModelMapper But, its not working due to the structure of the source, it has a list of strings .... Below is the snippet for the 3 main components source soap message, destination…
Mega
  • 1,304
  • 5
  • 22
  • 37
2
votes
0 answers

Is there a way to change default mapping?

I want to map a SourceClass type to a DestinationClass type. public class SourceClass { private Integer id; private String number; private String username; private String email; } public class DestinationClass { private…
黃昭維
  • 21
  • 3
2
votes
1 answer

How to convert entity with lazy properties into DTO using Java model mapper

I use Spring JPA with hibernate,WebFlux and have problems with it. I've tried to fetch some entities from database, but lazy load exception occurred when i try to convert my entity to DTO. I understand why it happen and i can avoid it by creating…
roma2341
  • 111
  • 2
  • 10
2
votes
1 answer

ModelMapper issue white converting from string to ObjectId

I have Entity (Course) and DTO (CourseDto) with spring boot as API server, backend as mongo @Document(collection = "courses") public class Course { @Id private ObjectId id; .... } public class CourseDto { private String id; …
user2869612
  • 607
  • 2
  • 10
  • 32
2
votes
0 answers

ModelMapper set parent id in child table bi-directional OneToMany

I'm using ModelMapper with Springboot and I'm trying to set the parent id in the child table, but the parent id continues to be null. Now I understand in hibernate you need to set the parent object within the child like so. class Parent { …
Code Junkie
  • 7,602
  • 26
  • 79
  • 141
2
votes
2 answers

How recursively update nested objects from one object by another use mapstruct or modelmapper?

Better i explain my task by an example of what I want to get. Is it possible to solve this use mapstruct / modelmapper / etc? class Person{ String name; Address address; } class Address{ String street; Integer home; } Updates: { …
2
votes
0 answers

Have ModelMapper ignore mapping fields that are JPA Lazy and haven't been initialized

If you've used JPA you've probably run into the classic org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: class, could not initialize proxy - no Session I'm using ModelMapper to map my hibernate objects…
AKrush95
  • 1,381
  • 6
  • 18
  • 35
2
votes
1 answer

ModelMapper Not Mapping

When I try to map String in a source to Integer in Destination via Enum. ModelMapper fails. Source public class Request { private String classification; } Destination public class DTO { private Integer classification; } Mapping between…
Jags
  • 47
  • 1
  • 6
2
votes
1 answer

Does using DTOs everywhere affect memory usage on jvm?

So my question is in my projects, I am using the model mapper in my Service classes. So when a service calls the Dao layer (Which actually just a JPA Repository interface), Dao layer returns the entity successfully now instead of just returning the…
Gurinder
  • 943
  • 2
  • 9
  • 19