jmapper-framework / jmapper-core

Elegance, high performance and robustness all in one java bean mapper
http://jmapper-framework.github.io/jmapper-core
Apache License 2.0
231 stars 41 forks source link

Mapping fields in one direction only #63

Closed tranba closed 7 years ago

tranba commented 7 years ago

I can't find out the way to mapping fields in one direction only. Can you add this feature? In Orika (https://orika-mapper.github.io/orika-docs/mappings-via-classmapbuilder.html) we can do like that: mapperFactory.classMap(BasicPerson.class, BasicPersonDto.class).fieldAToB("name", "fullName") ... .register();

avurro commented 7 years ago

Why do you need to force the mapping in one direction? the purpose of JMapper is to allow to reuse the same configuration as much as possible

tranba commented 7 years ago

I'm using JPA - Hibernate and JMapper to map entities to dtos. I want to my entities has not need setter for id property. For now, my workaround is write a setter method for id property in abstract entity class with empty body 😄

public void setId(Long id) {
}

Thank you! (Sorry for my English)

avurro commented 7 years ago

why you don't exclude the field from mapping? However I am happy that you have solved.

Add a star if you like the project, thank you!

tranba commented 7 years ago

I need id field in DTOs but not want to update entity's id. I am happy with my workaround too. So I will close this issues.