orika-mapper/orika

Using existing class maps multiple times with new fields

h-azycrazy opened this issue · 0 comments

On using same class map(same source and destination classes) twice with different field mappings, it registers the field mappings, but does not map the second time.

`public void map(Source source, Destination destination, Type sourceType,
Type destinationType) {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
MapperFacade mapperFacade = mapperFactory.getMapperFacade();

    mapperFactory.classMap(sourceType,destinationType).field("someField", "someField").register();
    mapperFacade.map(source,destination);       //Maps "someField" successfully

    mapperFactory.classMap(sourceType,destinationType)
                             .field("someOtherField", "someOtherField").register();
    mapperFacade.map(source,destination);       //Doesn't map "someOtherField"

}`

I have gone through the other questions that suggest using custom converters but i'm unable to implement so. Also i cannot create a new class. Can someone please create an informative guide to this? Thanks.