
Chapter 4 Generating Hibernate Persistent Objects and JSF Pages
DAO
The DAO is an abstraction layer. It hides the Hibernate specific features from the application. An application developed using DAO can switch to another persistence management engine (EJB 3.0, JDO 2.0, ...) without changing a single line of code. The only thing you need to change is the factory properties file.
The DAO provides helpers functions to simplify CRUD (Create, Read, Update, Delete) operations, session management, auto-commit, etc.
The following objects are involved:
- Dao interface - the base interface
- CustomerDao - the Customer specific Dao interface. It defines customer specific functions like find methods.
- HibernateDao interface - provides helper functions to simplify Hibernate operations. It wraps most of useful functions in Hibernate.
- HibernateDaoImpl class - implements the helper functions defined in the HibernateDao interface.
- CustomerDaoImpl class - implements the functions defined in the CustomerDao interface for Hibernate.
- Customer class - the persistent class.
- CustomerPK class - the primary key class of Customer.
- com.sybase.orm.dao package - defines the generic Dao interface and DaoException class.
- orders.daoimpl.hibernate package - defines the Hibernate specific implementation of Dao.
- <package>.dao package - defines the object specific abstract Dao interface.
- <package>.daoimpl.hibernate package - defines the object specific Dao implementation for Hibernate.
Copyright (C) 2005. Sybase Inc. All rights reserved.
|
|