SAP Implementation 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 do modification if requirement change.
Data Access Object <ul><li>Data Access Object (DAO) is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing details of the database. </li></ul><ul><li>This isolation separates the concerns of what data accesses the application needs, in terms of domain-specific objects and data types (the public interface of the DAO), and how these needs can be satisfied with a specific DBMS, database schema, etc. (the implementation of the DAO). </li></ul><ul><li>This design pattern is equally applicable to most programming languages, most types of software with persistence needs and most types of database, but it is traditionally associated with J2EE applications and with relational databases accessed via the JDBC API because of its origin in Sun Microsystems' best practice guidelines ("Core J2EE Patterns") for that platform. </li></ul>
Advatnages <ul><li>The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application which can and should know almost nothing of each other, and which can be expected to evolve frequently and independently. </li></ul><ul><li>Changing business logic can rely on the same DAO interface, while changes to persistence logic do not affect DAO clients as long as the interface remains correctly implemented. </li></ul><ul><li>In the specific context of the Java , Data Access Objects can be used to insulate an application from the particularly numerous, complex and varied Java persistence technologies , which could be JDBC , JDO , EJB CMP , TopLink , Hibernate , iBATIS , or many others. </li></ul><ul><li>Using Data Access Objects means the underlying technology can be upgraded or swapped without changing other parts of the application. </li></ul>
Implementation Steps Squirrel SQL Client and DAO4J can generate these codes, so we does not need to do from the scratch. We can take it as black box. We just need to focus on workflow design and author business objects. We don’t need to know how to do CRUD.
Class Diagram DAO Interface DTO Class The DTO Class which contains only the PK fields and can be used as the key of HashMap This table has more than 80-column, I’ll not show all attributes in class diagram DAO Impl DTO Class
Class Diagram We does not need to know the detail method operation, just call create method if we need to insert data into ERP interface table.
Source code snippet . . We just need to focus on how to retrieve all the necessary attributes, and set values to DTO Provide DTO and connection to create method. Then, everything is done.
ATTENTATION – Poor Exception Handling We need to add catch clause before finally clause