DAO 和 Data Mapper 有什么区别
DAO 模式和数据映射器模式之间有区别吗? DAO只是做Data Mapper的一种吗?
Is there a difference between the DAO pattern and the Data Mapper pattern? Is DAO just one of doing Data Mapper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实际上不会将 DAO 称为“模式”。 在我看来,DAO 几乎就是它的本质——一个“数据访问对象”,它封装了访问持久数据存储的细节,一般来说与数据库无关:
很明显,实现可以使用任一 DB (在这种情况下,使用数据映射器是非常合乎逻辑的,或者简单的 XML 文件存储机制
另一方面,数据映射器更多的是一种模式,它定义了一个负责将内存中的对象图转换为关系结构的层。 。
I wouldn't actually call DAO a "pattern". As I see it, DAO is pretty much what it is -- a Data Access Object", which encapsulates the details of accessing a persistent data store and generally speaking has nothing to do with the database:
It's clear that implementations can use either DB (in which case it's quite logical to use a Data Mapper), or simple XML file storage mechanism.
The Data Mapper on the other hand is more of a pattern, which defines a layer responsible for translating in-memory graphs of objects to the relational structure.