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

Will ModelMapper create intermediate objects?

From the example in the documentation... map().customer.setName(source.getPerson().firstName); If "customer" does not exist (is null) will ModelMapper create a new Customer object and setCustomer automatically, or do I have to create it beforehand?
user244277
0
votes
0 answers

Web Api ViewModel to DTO to ViewModel

I am starting a new Web API project and trying to still grasp the concepts of DTO / View Model.I know for a fact that your DTOs should only hold data and any required business rules should be performed on the DTO before finally it gets to the…
Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109
0
votes
2 answers

Custom mappings using ModelMapper library in managed beans results in NullPointerException

I get NullPointerException when I try to add mappings by creating my custom mapper in some container-managed objects. I tried it in @Stateless EJB service and @RequestScoped rest service. The error is similar and occurs in…
Ziemo
  • 941
  • 8
  • 27
0
votes
1 answer

ModelMapper: how to map this json to Java?

I am attempting to use ModelMapper to map the following json as explained here http://modelmapper.org/user-manual/gson-integration/ but I am getting a NullPointerException and I can't figure what is wrong. Any tips please? {"a": "aaa", "b": [{"c":…
dmz73
  • 1,588
  • 4
  • 20
  • 32
0
votes
0 answers

Verify test(s) exist for any source/destination mapped types

My understanding of "best practices" when using an automatic mapping tool like ModelMapper is to have unit tests for any source->destination map that occurs in your code, to be sure the mapping is doing what you expect. Is there any code…
Pete
  • 11,313
  • 4
  • 43
  • 54
0
votes
1 answer

Mapping validation property paths using bean mappers like ModelMapper, Orika or Dozer

Given that a bean mapper is used to map a Business Modell of into a DTO model and vice versa: Which one do provide easy ways to convert property paths? Lets say my business logic reports that "person.street.number" is mandatory and now I want tell…
bentolor
  • 3,126
  • 2
  • 22
  • 33
0
votes
1 answer

Copy Only String properties from one object to another

I was working with dozer and I had a special scenario which I think dozer doesn't support. Suppose I have a class with different type of properties like String,Ingeger and other primitive types. Now I want to copy only string property from this…
Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82
-1
votes
1 answer

How can i create two different map methods with ModelMapper for the same Source and Destination

Let's say i have the following classes class User { private String name: private Address address; // getters and setters } class UserDto { private String name: private Address address; // getters and setters } I already have…
-1
votes
1 answer

Need to Map incoming column to different field in model class

I am receiving jpa object from db using springboot and mapping it to model but the column name in model is different than the one coming from database. I tried to setter to set the value of model field from the incoming database attribute but the…
-1
votes
2 answers

Map List < Object > to List < ObjectSrv >

I want to Map List < City > to List < CitySrv > in the service layer but i dont have any idea how to do that. the City srv that i want to Map: (srv = server response value) @Getter @Setter @SuperBuilder @NoArgsConstructor @AllArgsConstructor …
Sajjad Serajzadeh
  • 334
  • 1
  • 3
  • 13
-1
votes
1 answer

What is the best way to convert entity to dto? For Spring REST API Application

I created an abstract class to generate the list of entities or dto using modelmapper in the inheriting class. Do you have any suggestions for a better way? For each class we need to create the toDTO and toEntity methods public abstract class…
Luca De Salve
  • 11
  • 1
  • 2
-1
votes
1 answer

When DTO has @NotNull, Mapping with ModelMapper does not throw exception?

My problem is that I have got a dto called PhoneBillPaymentDTO which has a field phoneNumber annotated with @NotNull. When I map this dto that has null phone number with ModelMapper to PhoneBillPayment Entity, it does not throw exception. How can I…
HiIamAnil
  • 11
  • 3
-1
votes
2 answers

Mapping object's related entities by other field than ID

I am using the following entities: @Entity @Table(name = "books") public class Book { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @ManyToOne private User user; private UUID uuid =…
wojtek1902
  • 503
  • 2
  • 10
  • 25
-1
votes
1 answer

CrudRepository not fetching Required List, instead Seeing PersistentBag Error

I have a simple RestController that returns a User Object after making calls to the DB by extending org.springframework.data.repository.PagingAndSortingRepository Interface. The Challenge now is when I make this call for UserObject, addresses return…
nwabudo
  • 11
  • 4
1 2 3
28
29