How to map persistent objects to DTO?

江枫思渺然 提交于 2019-12-08 12:57:59

问题


How to map persistent object to DTO? So that no additional behavior is taken. I know it is quite common and easy, but many people - many opinions, what are the best approaches?

(talking about Java)

Thanks,


回答1:


You could use a object mapper like Dozer.




回答2:


You can also use Orika it also support hetrogenous mapping with ease coding.




回答3:


Another alternative is MapStruct (disclaimer: I'm the original author of this project). MapStruct generates mapping code at compile-time which is thus fast and type-safe, i.e. you don't have any runtime dependencies and get feedback about incompatible mappings at build time, e.g. within your IDE.



来源:https://stackoverflow.com/questions/7650616/how-to-map-persistent-objects-to-dto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!