I'm trying to convert one object to another using ModelMapper and it's not working when submitting with multiple ids, the following implementations:
ModelMapper Config:
ScheduleRequest:
Schedule:
ScheduleMapper:
ScheduleController:
Request POSTMAN:
Final result:
CodePudding user response:
solved manually, but in a non-elegant way:
CodePudding user response:
It's not the problem with multiple IDs, it's about you have different data types. In ScheduleRequest, there are personId and examId with Long type, however in the Schedule entity object, there are person and exam fileds with Person and Exam type accordingly. ModelMapper works fine in this case.
Your solution is correct. But take care, if you set some kind of cascading for Person and Exam entities (CascadeType.MERGE), you will end up in data-loss! (Based on the class names and relations you will not set cascading :) )








