Context
Access to data varies depending on the source of the data. Access to persistent storage,
such as to a database, varies greatly depending on the type of storage (relational databases,
object-oriented databases, flat files, and so forth) and the vendor implementation.
Problem
Many real-world Java 2 Platform, Enterprise Edition (J2EE) applications need to use
persistent data at some point. For many applications, persistent storage is implemented with
different mechanisms, and there are marked differences in the APIs used to access these
different persistent storage mechanisms. Other applications may need to access data that
resides on separate systems. For example, the data may reside in mainframe systems,
Lightweight Directory Access Protocol (LDAP) repositories, and so forth. Another example
is where data is provided by services through external systems such as business-to-business
(B2B) integration systems, credit card bureau service, and so forth.
Typically, applications use shared distributed components such as entity beans to
represent persistent data. An application is considered to employ bean-managed persistence
(BMP) for its entity beans when these entity beans explicitly access the persistent
storage-the entity bean includes code to directly access the persistent storage. An
application with simpler requirements may forego using entity beans and instead use
session beans or servlets to directly access the persistent storage to retrieve and modify the
data. Or, the application could use entity beans with container-managed persistence, and
thus let the container handle the transaction and persistent details.
Applications can use the JDBC API to access data residing in a relational database
management system (RDBMS). The JDBC API enables standard access and manipulation
of data in persistent storage, such as a relational database. The JDBC API enables J2EE
applications to use SQL statements, which are the standard means for accessing RDBMS
tables. However, even within an RDBMS environment, the actual syntax and format of the
SQL statements may vary depending on the particular database product.
There is even greater variation with different types of persistent storage. Access
mechanisms, supported APIs, and features vary between different types of persistent stores
such as RDBMS, object-oriented databases, flat files, and so forth. Applications that need to
access data from a legacy or disparate system (such as a mainframe, or B2B service) are
often required to use APIs that may be proprietary. Such disparate data sources offer
challenges to the application and can potentially create a direct dependency between
application code and data access code. When business components-entity beans, session
beans, and even presentation components like servlets and helper objects for JavaServer
Pages (JSP) pages --need to access a data source, they can use the appropriate API to
achieve connectivity and manipulate the data source. But including the connectivity and
data access code within these components introduces a tight coupling between the
components and the data source implementation. Such code dependencies in components
make it difficult and tedious to migrate the application from one type of data source to
another. When the data source changes, the components need to be changed to handle the
new type of data source.
Forces
Components such as bean-managed entity beans, session beans, servlets, and other
objects like helpers for JSP pages need to retrieve and store information from persistent
stores and other data sources like legacy systems, B2B, LDAP, and so forth.
Persistent storage APIs vary depending on the product vendor. Other data sources
may have APIs that are nonstandard and/or proprietary. These APIs and their capabilities
also vary depending on the type of storage-RDBMS, object-oriented database management
system (OODBMS), XML documents, flat files, and so forth. There is a lack of uniform
APIs to address the requirements to access such disparate systems.
Components typically use proprietary APIs to access external and/or legacy systems
to retrieve and store data.
Portability of the components is directly affected when specific access mechanisms
and APIs are included in the components.
Components need to be transparent to the actual persistent store or data source
implementation to provide easy migration to different vendor products, different storage
types, and different data source types.
Solution
Use a Data Access Object (DAO) to abstract and encapsulate all access to the data
source. The DAO manages the connection with the data source to obtain and store data.
The DAO implements the access mechanism required to work with the data source.
The data source could be a persistent store like an RDBMS, an external service like a B2B
exchange, a repository like an LDAP database, or a business service accessed via CORBA
Internet Inter-ORB Protocol (IIOP) or low-level sockets. The business component that relies
on the DAO uses the simpler interface exposed by the DAO for its clients. The DAO
completely hides the data source implementation details from its clients. Because the
interface exposed by the DAO to clients does not change when the underlying data source
implementation changes, this pattern allows the DAO to adapt to different storage schemes
without affecting its clients or business components. Essentially, the DAO acts as an adapter
between the component and the data source.
- 浏览: 15482 次
- 性别:
- 来自: 北京
文章分类
最新评论
发表评论
-
集成层模式:Service Activator—服务激发器模式
2014-04-09 20:31 1116ContextEnterprise beans and o ... -
业务层模式:Service Locator—服务定位器模式
2014-04-09 20:31 1174ContextService lookup and cre ... -
表示层模式:Value List Handler—值列表处理器模式
2014-04-09 20:32 775ContextThe client requires a ... -
表示层模式:Transfer Object Assembler—传输对象组装器模式
2014-04-10 22:48 768ContextIn a Java 2 Platform, ... -
业务层模式:Composite Entity—复合实体模式
2014-04-08 21:38 505ContextEntity beans are not i ... -
业务层模式:Session Facade—会话门面模式
2014-04-08 21:38 426ContextEnterprise beans encap ... -
业务层模式:Transfer Object—传输对象模式
2014-04-08 21:37 437ContextApplication clients ne ... -
业务层模式:Business Delegate—业务委托模式
2014-04-08 21:37 987ContextA multi-tiered, distri ... -
表示层模式:Dispatcher View—分发者视图模式
2014-04-08 21:37 546ContextSystem controls flow o ... -
表示层模式:Service to Worker—工作者服务模式
2014-04-07 10:48 993ContextThe system controls flow ... -
表示层模式:Front Controller—前端控制器模式
2014-04-07 10:45 382ContextThe presentation-tier re ... -
表示层模式:Composite View—复合视图模式
2014-04-07 10:41 492ContextSophisticated Web page ... -
表示层模式:View Helper—视图助手模式
2014-04-07 10:37 1035ContextThe system creates pre ... -
表示层模式:Intercepting Filter—拦截过滤器模式
2014-04-07 10:29 630Context The presentati ...
相关推荐
DAO(Data Access Object)是数据库访问对象,是Microsoft Access中用于与数据库进行交互的一种编程模型。DAO对象模型允许程序员通过VBA(Visual Basic for Applications)语言来设计和编写处理数据的函数和过程,...
3. 高性能:Oracle.DataAccess优化了对Oracle数据库的访问,提供了预编译的SQL语句(OraclePreparedStatement)和批处理功能,以提高数据处理速度和降低网络通信开销。 4. 支持Oracle特性:包括Oracle特定的数据...
OPC Data Access Components 2.0组件是专为配置OPC客户端而设计的重要软件组件,它使得应用程序能够高效地访问工业自动化设备的数据。OPC,全称OLE for Process Control,是一种标准接口,允许不同的硬件和软件系统...
数据访问对象(DAO,Data Access Object)是一种设计模式,它在软件工程中被用来封装对数据库的操作,使得业务逻辑层与数据存储层之间的耦合度降低。DAO模式的主要目标是提供一个接口,通过这个接口,应用程序可以...
这个“OPC DATA ACCESS COMPONENTS.rar”压缩包很可能包含了实现OPC数据访问功能的组件或库,供开发人员在自己的应用程序中集成OPC功能。 OPC数据访问组件主要由以下几部分构成: 1. **OPC服务器**:这是OPC技术的...
在.NET框架中,C#语言被广泛用于Web应用程序的开发,特别是在构建企业级应用时,数据访问层(Data Access Layer, DAL)的设计和实现至关重要。数据访问层是应用程序与数据库交互的桥梁,它封装了所有与数据库操作相关...
本实例“OLD-DB.rar_Access OLE Object_vc读取ole对象”聚焦于如何利用VC++6.0这一经典开发环境,通过ActiveX Data Objects (ADO)来操作Access数据库中的OLE对象。下面我们将深入探讨相关的知识点。 1. **OLE对象**...
在“OPC Data Access Automation Interface Standard 2.02”中,我们主要关注的是这一接口的自动化版本,这允许开发者通过自动化技术来访问和控制OPC服务器中的数据。以下是这个规范中涉及的一些关键知识点: 1. **...
IBatis.Net框架(包括IBatis.DataMapper和IBatis.DataAccess)为.NET开发者提供了一个强大且灵活的数据访问解决方案。它简化了数据库操作,减少了开发时间,并提高了代码的可维护性。通过XML配置文件,开发者可以...
- 集成层模式:Data Access Object、Service Activator等。 这些模式各自代表了解决特定问题的通用解决方案,并且在J2EE应用开发中被广泛采用。 此外,书籍的后记部分强调了设计模式的价值,将其比喻为开发过程中...
2. DAO(Data Access Object)模式:每个DAO代表一个数据表,提供特定的数据操作方法。 六、网络数据访问 对于远程服务器的数据交互,Android提供了诸如Retrofit、Volley、OkHttp等网络库。这些库可以帮助我们构建...
6. **DAO(Data Access Object)模式**:通过接口定义数据访问操作,实现与具体数据库操作的解耦。每个DAO接口对应数据库中的一个表,提供增删改查等基本操作。 7. **事务管理**:在多条数据库操作需要一起成功或...
6. **DAO(Data Access Object)模式**:Spring推荐使用DAO模式来组织数据访问层,这样可以将业务逻辑和数据访问逻辑分离,提高代码的可测试性和可维护性。 7. **AOP(面向切面编程)**:Spring的AOP功能可用于实现...
Spring Data Access Object(DAO)框架是Spring生态体系中用于数据库交互的重要部分,它简化了数据访问层的实现,使得开发者可以更专注于业务逻辑,而不是底层数据库操作。本文将深入探讨Spring DAO框架的入门知识,...
3. DAO(Data Access Object)模式:这是一种设计模式,它定义了一个接口来封装对数据库的所有操作,使得业务逻辑层与数据访问层解耦。DAO类通常包含了对JDBC或ORM的调用。 4. Transaction Management:事务管理是...
通过SpringData,开发者可以避免编写大量重复的DAO(Data Access Object)层代码,提高开发效率。 2. **JPA与SpringData**: JPA是Java EE中用于对象关系映射的标准API,SpringData通过集成JPA,使得开发者可以...
3. **数据访问层(Data Access Layer)**:负责与数据库的交互,包括数据的读取、写入、更新和删除等操作。这一层通常使用ORM(Object-Relational Mapping)工具或自定义SQL语句来实现,确保数据操作的原子性和一致...
RegPreciseDao是一个针对RegPrecise数据库的数据访问对象(DAO,Data Access Object)框架,主要用于简化Java开发人员与RegPrecise数据库之间的交互。在Java编程中,DAO模式是一种设计模式,它提供了一种抽象层,...
在Spring中,数据访问层(Data Access Layer)是应用程序的重要组成部分,它负责与数据库进行交互,执行CRUD操作(创建、读取、更新和删除)。Spring通过其IoC(控制反转)和AOP(面向切面编程)特性简化了这一过程...
Java DAO(Data Access Object)模式是一种常见的设计模式,主要用于封装对数据库的操作,使得业务逻辑与数据访问逻辑分离,提高代码的可复用性和可维护性。在本课程设计中,学生将通过实践来理解和掌握这一模式。 ...