mardi 12 septembre 2017

ignore fields from target class which isn't in target class. MapStruct

I have a problem with mapping fields from through MapStruct.

I have two classes. First domain class "Event" for example with fields 1) id. 2) lastUpdate. 2) type. 3) participants. 4) description.

And Second class is "EventForm". EventForm have fields: 1)Type. 2)participants 3)description.

And when I want to update an existing event, the following happens: 1) I get an existing event from database by Id

Event event = eventService.get(id);

And event have id = 10000, lastUpdate=11213123123;

2) I am mapping fileds from form to domain class

event = mapper.eventFormToEvent(eventForm)

3) After that event have NULL value in id and lastUpdate values.

How ignore all unmapped fields in target class ? Thanks.




Aucun commentaire:

Enregistrer un commentaire