Instead of additional dependency for modelmapper, there is BeanUtils class which is part of spring framework it provides copy method for copying properties from one object to another object
@@SeleniumExpress Using Constructor Mapping You can define a constructor in the DTO that takes an entity object as a parameter. This reduces the amount of boilerplate code. Example: ResponseDTO with Constructor: java Copy code public class EmployeeResponseDTO { private Long id; private String name; public EmployeeResponseDTO(Employee employee) { this.id = employee.getId(); this.name = employee.getName(); } // Getters } Usage: Employee employee = employeeRepository.findById(1L).orElseThrow(); EmployeeResponseDTO dto = new EmployeeResponseDTO(employee);
Thanks Mani for the kind words. ❤️ You can choose any one of it for learning. Once you have a project assigned, the you can work on whatever that comes in your way.
Thank you abhilash....! . I haven't seen this kind of clean and good content presentation anywhere. It was a great learning experience. Thank you once again and keep it up.
In address response we dont have employee id and also in the repository query. When I use the same process, I am getting error like column for employee id not found. Unless I add the employee id in the native query and response class, the issue doesn't resolve. How to handle this ?
Hi Abhilash, kudos for providing this kind of content on RU-vid. I request you to make a tutorial on junit/mocking when u get free time Thanks in advance 😊
Sir kindly explain, why are we manually creating database and table ? Is the objective of jpa repository to create the database and table automatically ?
Thank you abhilash....! can you make video on merging 2 APi calls to 2 different micro-services (each having their own db copy) as one using say GrpahQl or CQRS in this series
Thank you for the great video! Is it possible to use h2-database with microservices (not in Production. Only during development). Assume that I load the database from a file and not from the memory. How am I going to set the relationship between Employee Service and Address Service (1 to 1) if they are actually a different application? Can I do something like this or it is impossible to do with an H2 database? Thank you in advance!
your courses are good just a suggestion also include the error handling scenarios for the people who are new to this can get along with other things also.
Hi Bro,It's a wonderful explanation..thank you very much for your support.but I have one doubt on importance of model mapper with and without.. please explain 😊
Hi Prasad, without a mapper it will be difficult to manually copy all your entity properties to dto/model properties, considering a scenario you got 30 properties inside your dto
Hi Bharath, then we got to manually map using another overloaded map method. There are different patterns matches that model mapper provides us. Please refer the model mapper doc. I will be creating few contents on model mapper and different mapping api in coming days.
I am so confused in databases. Before you said that in microservices architecture, each service has separate database. But here you make common database for address and employee service. Maybe you will tell us how to join tables, when services has own database?
It is not a good practice to return the actual entity to the user. This is why we use another class as a return type. For instance, assume we have an entity with 30 properties and we want to return to the user only some of them. We will have to create another class, in which we will map the values (only the properties we want to return to the user) from the entity to the response class and return the response class back to the user.
when iam going to practice same things in my sts, i am getting hibernate package as jarkata.persistence but for you javax.persistence, how you are getting that? can you please respond?