简体   繁体   中英

How to map persistent objects to DTO?

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,

您也可以使用Orika,它还支持轻松编码的hetrogenous mapping。

您可以使用像Dozer这样的对象映射器。

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, ie you don't have any runtime dependencies and get feedback about incompatible mappings at build time, eg within your IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM