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

Using Modelmapper, how do I map to a class with no default/no-args constructor?

I want to map to a source destination which only have a constructor that takes 3 parameters. I get the following error: Failed to instantiate instance of destination com.novasol.bookingflow.api.entities.order.Rate. Ensure that…
Lars Rosenqvist
  • 421
  • 7
  • 17
5
votes
3 answers

ModelMapper: How to map List which is passed as generic?

I have an abstract class: public abstract class AbstractBeanDTO extends AbstractBigDTO { protected T value; //getter setter } The extending class has the generic type List public class ItemsBeanDTO extends AbstractBeanDTO> { } Im…
Daffy
  • 140
  • 2
  • 13
5
votes
1 answer

Java ModelMapper: map DTO to EmbeddedId entity class

I want to know if it's possible to map a DTO to an entity class with a composite pk. I've been reading ModelMapper documentation about PropertyMap but I can't make it work. Here is the code: PlanDTO: public class PlanDTO implements Serializable { …
5
votes
0 answers

Java ModelMapper -Failed to convert java.util.List to java.util.List

I am using the Java ModelMapper library to map DTOs to ORM @Entity objects. I have the following test set up: public class MapperTest { @Autowired private ModelMapper mapper; @Autowired private TicketRepository ticketRepo; …
KellyM
  • 2,472
  • 6
  • 46
  • 90
5
votes
3 answers

NullPointerException when trying to define a custom PropertyMap

I'm using ModelMapper the following way : I have a few converter classes that are Spring components and they register custom ModelMapper mappings @Component public class FooConverter { @Autowired private ModelMapper modelMapper; public…
Marc
  • 16,170
  • 20
  • 76
  • 119
5
votes
3 answers

DateConverter failed to convert java.lang.String to java.util.Date. Caused by: org.modelmapper.MappingException: ModelMapper mapping errors:

I'm trying to use modelmapper to map my Class with the incoming request. It looks like Date is not able to auto convert in modelmapper. Converter org.modelmapper.internal.converter.DateConverter@7595415b failed to convert java.lang.String to…
Jayendran
  • 9,638
  • 8
  • 60
  • 103
5
votes
1 answer

how to exclude whole property if they are null from Modelmapper

Does ModelMapper(http://modelmapper.org/) support what exclude property? If the value is null. I just found PropertyMap out. but It is a constraint to me. because I have to describe a specific property that I want. Like this. ModelMapper…
Brady
  • 101
  • 1
  • 2
  • 8
5
votes
6 answers

Spring ModelMapper error: Mapping already exists for controller

I am getting data from my form through a DTO and mapping it to my Hibernate entity. I wanted to skip a date field as the incoming data is all strings and I need to convert the string field into a date separately from other fields. The rest of the…
supriyo_basak
  • 505
  • 1
  • 7
  • 24
5
votes
1 answer

ModelMapper: Map collections to collections of other structure

I map business objects to entities and there are cases where the structure of an entity is different from the business objects. I have userCategories which are stored in the business object RecipeBo as strings, because the BO does not have to know…
Bevor
  • 8,396
  • 15
  • 77
  • 141
5
votes
1 answer

How to map from a Map to List

I'm working on a project where I need to map from a hierarchical Map where the second parameter is expected to be a String or Map. Thus far, ModelMapper has worked awesome, but I'm having trouble with a specific…
ironhardchaw
  • 149
  • 3
  • 10
5
votes
1 answer

Custom converter for Jooq Result

Actually we are using fetchInto() to convert the results to list of object. For example: Employee pojo matching database table is employee. List employeeList = sql.select(Tables.Employee) …
Syed Shahul
  • 481
  • 4
  • 16
4
votes
1 answer

ModelMapper & JPA: How to map DTO with id to Entity with oneToMany field

ModelMapper has been working great for converting my entities to DTOs, but i'm having trouble going the other way around since most of my entities have at least one field that's another entity itself. Group: @Entity @Table(name =…
Ari_Scher
  • 41
  • 3
4
votes
0 answers

Can I map to a non default constructor with ModelMapper without defining any custom TypeMaps or so?

I work with immutable objects. I would like to map from one to another immutable object with org.modelmapper.ModelMapper. If I do that just like this I'm getting an exception Failed to instantiate instance of destination com.MyImmutableObject.…
Herr Derb
  • 4,977
  • 5
  • 34
  • 62
4
votes
2 answers

ModelMapper mapping the wrong id

I have an issue while mapping a dto to an entity with nested objects. Basically a "DayEntry" cotains many "SingleEntry" and each "SingleEntry" has a "Category". Here are my entities : @Entity public @Data class SingleEntry { @Id …
Bacem
  • 43
  • 1
  • 4
4
votes
0 answers

How to map modified, not matching the destination, source value, using the model mapper?

I have two API entities (EntityA and EntityB) that implement BaseEntity. Both entities have the nullable parameter identifier. @Value @Builder(builderClassName = "Builder") public class EntityA implements BaseEntity { String…
Gene Zeiniss
  • 137
  • 12
1 2
3
28 29