DAO和数据传输对象

编程入门 行业动态 更新时间:2024-10-28 04:23:38
本文介绍了DAO和数据传输对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,在数据传输对象"中,应仅包含setter和getter.但是,如何处理还从数据传输对象中插入和删除对象呢?

So in the Data transfer Object there should be only setters and getters.. However what about handling also inserting and deleting objects from the Data transfer Object?

public class dto{ setters and getters... .. .. public void delete(){ CustomreDao.delete(this.ID); } }

会违背DAO模式本身吗?

Would it be against the DAO pattern itself?

谢谢.

推荐答案

问一下自己:更新DAO的delete方法有多困难?"如果您有很多DTO,并且突然需要更改DAO,那么您要做的就是很多工作.

Ask yourself this: "how hard would it be to update the DAO's delete method?" If you have a lot of DTOs and suddenly need to change the DAO, then that's a lot of work you just created for yourself.

将DTO连接到DAO的责任留在其他地方,您可以在此从单个点控制交互.

Leave the responsibility of connecting the DTO to the DAO to something else, where you could control the interaction from a single point.

更多推荐

DAO和数据传输对象

本文发布于:2023-07-27 11:41:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222267.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据传输   对象   DAO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!