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
3
votes
0 answers

ModelMapper immutable DTO custom mapping

I have an immutable DTO with all fields final, having only getters and no setters. How can I use ModelMapper to add custom mapping from my entity to this DTO? Documentation shows usage with mapping getters to setters, but my DTO has no setters…
cdalxndr
  • 1,435
  • 1
  • 15
  • 20
3
votes
1 answer

Spring Boot Modelmapper - StackOverflowError: null

Im getting 1) Error mapping entity.Team to TeamDTO followed by java.lang.StackOverflowError: null without any really cause or line in the stacktrace. Im trying to fetch an entity from database by…
b0zz65
  • 41
  • 3
3
votes
1 answer

Map jooq record data to multiple pojos

We have multiple tables like : School one to many teacher teacher one to many subject teacher one to many classes Entity are as follows public class School { private String name; private long id; private…
GauravRatnawat
  • 717
  • 1
  • 11
  • 25
3
votes
3 answers

ModelMapper: how to keep converters registered at mapper level when using a TypeMap with custom mapping

I use ModelMapper to convert Models to DTOs. I have a bunch of default converters for null values that have been registered at the mapper level like this: modelMapper.addConverter(new Converter() { @Override …
Guillaume
  • 5,488
  • 11
  • 47
  • 83
3
votes
2 answers

How to deep select Nodes based on given depth in Java?

I have json representation like below: { "total": "555", "offset": "555", "hasMore": "false", "results": [ { "associations": { "workflowIds": [], "companyIds": [], "ownerIds": [], "child": { …
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62
3
votes
1 answer

ModelMapper: Incorect property mapping from null objects

I'm trying to map source object which property is set to null to destination object of which this property is set to another object. Expected result would be that property of destination object will be null after mapping. Instead of that, this…
Tuom
  • 596
  • 5
  • 19
3
votes
2 answers

How to have ModelMapper.validate() succeed when using converters and providers instead of property mapping?

Having something like: @Getter @Setter public static class Entity { private int hash; private LocalDateTime createdTime; } and @Getter @Setter public static class DTO { private String hash; private String createdTime; } I need…
pirho
  • 11,565
  • 12
  • 43
  • 70
3
votes
1 answer

ModelMapper failed to convert java.lang.String to java.lang.Long

I have rest models that I use to build JSON that I send. A rest model @Getter @Setter @ToString public class OrderRequestModel { private String orderKeyId; private String paymentMode; private double totalAmount; private…
davidvera
  • 1,292
  • 2
  • 24
  • 55
3
votes
2 answers

When i upgraded java version to openJDK 11, I am getting nullpointerException while loading modelmapper configurations

After upgrading Java version to openJDK 11, modelMapper configurations are not getting loaded, getting NullPointerException. NullPointerException issue is not resolved even after upgrading modelMapper version to 2.3.2 Error Log: 1) Failed to…
Shankar
  • 31
  • 1
  • 3
3
votes
3 answers

ModelMapper not ignoring null values

I want to do a partial update on one of my entities but if one propertie is null then the entity to be updated gets that value set to null too. I want that if a property from the source is null then to keep the one from the source. I have tried this…
Wrong
  • 1,195
  • 2
  • 14
  • 38
3
votes
2 answers

Why does ModelMapper map collections merge-style?

In my application I am mapping data transfer objects to entities using the ModelMapper library. One entity Library has a collection (java.util.Set) containing other entities Book. A user should be able to change the collections contents. In this…
Daniel
  • 458
  • 5
  • 16
3
votes
3 answers

Convert a JsonNode to Object with ModelMapper

I tried several times, but I can not solve it and I need help. I want JsonNode to Object JsonNode : { "usdusd" : 1.00, "usdkrw" : 1100 } MyObject public class MyObject { private BigDecimal usd; private BigDecimal krw; } How can I…
bassseo
  • 181
  • 1
  • 8
3
votes
1 answer

ModelMapper JUnit Mockito throws NullPointerException

I'm trying to test a method in service class which uses ModelMapper to convert entity to dto, but I'm getting NullPointerException at this line mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); in the service…
budthapa
  • 974
  • 14
  • 22
3
votes
2 answers

Spring boot issue with mapping entity to entityDTO

I am using spring-boot-1.5.6 and modelmapper-1.1.0. I would like to map the entity object to OrderDto but don't know how to do it via modelMapper. Please find the below code Order.Java public class Order { private String orderUid; private…
VelNaga
  • 3,593
  • 6
  • 48
  • 82
3
votes
1 answer

ModelMapper with STRICT Matching Strategy

I have the following Entity Classes: class Provider{ private String providerId; private String identificationNumber; private Account account; // Setters, Getters and toString } class Account { private String name; private…
AlejoDev
  • 4,345
  • 9
  • 36
  • 67