HOME      PRODUCTS      CUSTOMERS      BUY      CORPORATE     SUPPORT

PRODUCT BENEFITS     DOCUMENT LIBRARY     FIRESTORM/DAO DOWNLOAD      PRESS RELEASES

CodeFutures

 

J2EE Design Pattern: Data Access Object

Data Access Object J2EE Design Pattern

Business applications almost always need access to data from relational or object databases and the Java platform offers many techniques for accessing this data, the best of wich use the DAO J2EE Design Pattern. The oldest and most mature technique is to use the Java Database Connectivity (JDBC) API, which provides the capability to execute SQL queries against a database and then fetch the results, one column at a time. Although this API provides everything a developer needs to access data and to persist application state, it is a cumbersome API to develop against - which makes a code generator particularly useful.

Java 2 Enterprise Edition (J2EE) offers a newer persistence framework in the form of Entity Beans, a subset of the Enterprise JavaBean (EJB) framework. Although there have been many improvements in the more recent EJB 2.0 specification, many developers are now looking to alternative persistence frameworks, such as Java Persistence API (JPA) and Hibernate.

The Benefits of the J2EE Design Pattern Data Access Objects

The Data Access Object (DAO) J2EE Design Pattern provides a technique for separating object persistence and data access logic from any particular persistence mechanism or API. There are clear benefits to this approach from an architectural perspective. The DAO J2EE Design Pattern approach provides flexibility to change an application's persistence mechanism over time without the need to re-engineer application logic that interacts with the DAO J2EE Design Pattern tier. For example, there may be performance benefits in changing an application's performance mechanism from using Entity Beans to using direct JDBC calls from a session bean, or even a move to an alternative persistence framework, such as JDO. Without a DAO J2EE Design Pattern tier in place, this sort of transition would require extensive re-engineering of existing code.

The DAO design pattern also provides a simple, consistent API for data access that does not require knowledge of JDBC, EJB, or JDO interfaces. A typical DAO J2EE Design Pattern interface is shown below.

public interface CustomerDAO
{
  public void insert(Customer customer)
   throws CustomerDAOException;

  public void update(CustomerPK pk, Customer customer)
   throws CustomerDAOException;

  public void delete(CustomerPK pk)
   throws CustomerDAOException;

  public Customer[] findAll()
   throws CustomerDAOException;

  public Customer findByPrimaryKey(String email)
   throws CustomerDAOException;

  public Customer[] findByCompany(int companyId)
   throws CustomerDAOException;
}

It is important to note that DAO J2EE Design Pattern does not just apply to simple mappings of one object to one relational table, but also allows complex queries to be performed and allows for stored procedures and database views to be mapped into Java data structures.

Additional useful information on Data Access Objects J2EE Design Pattern is available here;

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm

Minimizing the Impact of Moving to DAO

CodeFutures' objective is to minimize the importance of the main argument against using DAO J2EE Design Pattern: the fact that it requires a significant amount of repetitive source code to be produced for no immediate advantage over using JDBC, EJB, or JDO directly. For many developers, this disadvantage is good enough reason to ignore the long-term benefits of using a framework-neutral API, especially where there are strict project deadlines. Without the code generation advantages of FireStorm/DAO, it is not easy to justify to a project manager or project sponsor the time and cost of manually writing DAO code, regardless of any future benefits they may see.

DAO J2EE Design Pattern Code Generation

CodeFutures' solution to the manual coding problem is to automate the production of a DAO J2EE Design Pattern tier, as well as automating the actual implementation logic for whichever persistence framework is deemed appropriate for an application. This approach is easy to adopt because almost all databases use a standard language for defining their structure (SQL).

Additional Reading on Design Patterns

EJB Design Patterns by Floyd Marinescu
http://www.theserverside.com/books/wiley/EJBDesignPatterns/index.tss

The Hillside Group
http://hillside.net/patterns/onlinepatterncatalog.htm

JavaWorld list of  design pattern articles
http://www.javaworld.com/columns/jw-java-design-patterns-index.shtml

The  Design Patterns Java Companion
http://www.patterndepot.com/put/8/JavaPatterns.htm

Data and Object Factory
http://www.dofactory.com/patterns/Patterns.aspx

A Learning Guide To Design Patterns
http://www.industriallogic.com/papers/learning.html

Design Patterns (good quality personal page)
http://home.earthlink.net/huston2/dp/patterns.html

Product Information

 FireStorm/DAO Overview (PDF)
Provides brief (2 pages) introduction to FireStorm/DAO, the product benefits, and the product editions.

 FireStorm/DAO Architect Edition Overview (PDF)
Provides brief (2 pages) introduction to Architect Edtion, the product benefits, and using the Architect Edition with development teams.

 FireStorm/DAO Technical Overview (PDF)
Provides detailed technical overview of FireStorm/DAO.

Click on a product edition for more details or view an overview of the product range.

FireStorm/DAO Enterprise Edition generates JDBC, JDO, and EJB source code

Enterprise Edition

FireStorm/DAO Architect Edition allows custom code generators to be built

Architect Edition

Download FireStorm/DAO

FireStorm is available for free evaluation. The evaluation license is time-limited (but can be renewed) and functionality limited (the number of database tables is restricted and some features are disabled).

Please fill out the form below to receive an email with the location of the FireStorm download page and an evaluation license key.

1. Personal Details

Email address: Please verify email address is correct
First Name:
Last Name:
Company Name:
Country:

2. Terms and Conditions

I agree to comply with the terms and conditions in the license agreement contained within the product.

I would like to subscribe to the CodeFutures mailing list. This is a low volume list with roughly one email per month.


Reminder: Have you used a valid email address?

You will probably find that Hotmail, Yahoo! Mail, Gmail, OperaMail, and other Web-based email addresses do not work.

A valid email address is required to receive the download information.

Note: Does your company have a spam filter or corporate firewall? This may block the email with the license key. Please email sales@codefutures.com if you do not receive a response within a few minutes.




 

Products:

FireStorm/DAO

FireStorm/SDO

FireStorm/DAO:

Product Overview

Product Benefits

Technical Feature List

Technical Architecture

DAO Background

Technical Tutorial

FireStorm/DAO FAQs

Evaluation Download

Weblogs:

Corporate Weblog

Press Releases

Buy FireStorm/DAO Developer Support:

Support Pricing

Online Payment

Authorized Distributors

Purchase Orders

Educational Program

Product Delivery

Newsletter:

Newsletter Subscription


Customer Testimonial

"Before we discovered FireStorm/DAO, we were reluctant to write DAO code ourselves as it required a lot of time and effort. Now we can concentrate on the real business logic and application requirements."
Kobus Steenekamp, Senior Java Developer, Discovery Health





   
 
  FireStorm/DAO is a code generator for Java persistence that generates Data Access Objects based on Java DAO, JDBC DAO, Hibernate Java Persistence, JPA Persistence, and Spring DAO.

 

Copyright © 2003-2008 CodeFutures Corporation. All rights reserved.

APPLICATION DEVELOPMENT PRODUCTIVITY™
 
Data Persistence | Data Access Object
Site Map | Java Persistence | Legal
Data Transfer Object | Hibernate Java

FireStorm/DAO™, FireStorm/SDO™, and CodeFutures™ are trade marks of Code Futures Software Ltd.