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


i have problem mapping fields through mapstruct.

i have 2 classes. first domain class "event" example fields

1) id 2) lastupdate 2) type 3) participants 4) description 

and second class "eventform". eventform have fields:

1) type 2) participants  3) description 

and when want update existing event, following happens: 1) existing event database id

event event = eventservice.get(id);

and event have id = 10000, lastupdate=11213123123;

2) mapping fields form domain class

event = mapper.eventformtoevent(eventform)

3) after event has null value in id , lastupdate values.

how ignore unmapped fields in target class?

i specify need unmapped fields ignore, not 1 one

what looking updating bean instances. need use use case. uses @mappingtarget annotation.

your mapper like:

@mapper public interface mymapper {      void update(@mappingtarget event event, eventform eventform); } 

or:

@mapper public interface mymapper {      event update(@mappingtarget event event, eventform eventform); } 

in second case, mapstruct, returns passed event back. have keep in mind parameter passed @mappingtarget must not null.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -