Mapping between objects with default value

In this post under MapStruct, I will show with example how to map two objects with default value. Let me further elaborate the requirement. We have “Student” class and we have to map the instance of “Student” class to an instance of “StudentDTO” class. During mapping if the value of “className” attribute in “Student” class…… Continue reading Mapping between objects with default value

Mapping from multiple objects to one destination object

In this post under MapStruct, I will explain with example how to map attributes from multiple objects to attributes of one single destination object. For our example I will two source class as shown below Person package package4; public class Person { private int id; private String name; private int age; private char sex; //Removed…… Continue reading Mapping from multiple objects to one destination object

Skipping mapping of particular attribute

In this post under MapStruct, I will show with example how to configure MapStruct to skip particular attribute mapping from source to destination. For our example I will use the below pojo classes as shown below Student package package3; public class Student { private int id; private String name; private String className; public int getId()…… Continue reading Skipping mapping of particular attribute

Object Mapping between classes with different attributes

In the previous post under MapStruct I showed an example of how to use MapStruct framework for object mapping. I assumed that attribute names in source class and destination class are same. What if they are not. In this post, I will show with an example how to configure MapStruct to map between source and…… Continue reading Object Mapping between classes with different attributes