内容简介:翻译自:https://stackoverflow.com/questions/28703401/conversion-of-dto-to-entity-and-vice-versa
我想你在询问在哪里写整个实体 – > DTO转换逻辑.
喜欢你的实体
class StudentEntity { int age ; String name; //getter //setter public StudentDTO _toConvertStudentDTO(){ StudentDTO dto = new StudentDTO(); //set dto values here from StudentEntity return dto; } }
你的DTO应该是这样的
class StudentDTO { int age ; String name; //getter //setter public StudentEntity _toConvertStudentEntity(){ StudentEntity entity = new StudentEntity(); //set entity values here from StudentDTO return entity ; } }
你的控制器应该是这样的
@Controller class MyController { public String my(){ //Call the conversion method here like StudentEntity entity = myDao.getStudent(1); StudentDTO dto = entity._toConvertStudentDTO(); //As vice versa } }
翻译自:https://stackoverflow.com/questions/28703401/conversion-of-dto-to-entity-and-vice-versa
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- EF架构~FluentValidation实体检验与实体分离了
- 表单 – 如何使用实体列表(CRUD)从模板中删除实体?
- MyBatis Generator配置文件--指定生成实体类使用实际的表列名作为实体类的属性名
- 命名实体识别技术
- XML实体扩展攻击
- [DeepNLP] 初识命名实体识别
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Mission Python
Sean McManus / No Starch Press / 2018-9-18 / GBP 24.99
Launch into coding with Mission Python, a space-themed guide to building a complete computer game in Python. You'll learn programming fundamentals like loops, strings, and lists as you build Escape!, ......一起来看看 《Mission Python》 这本书的介绍吧!
CSS 压缩/解压工具
在线压缩/解压 CSS 代码
RGB CMYK 转换工具
RGB CMYK 互转工具