Usage of Data Access Object and Entity beans
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tony_Clarke
Posted On:   Tuesday, November 25, 2003 01:55 AM

Recently I have begun to look at the Data Access Object (DAO) design pattern. One book I read used this pattern as part of a persistance framework. However they put the DAO object in front of the Entity bean. I thought it was meant to be the other way around with the entity bean delegating to the dao. Are designs valid?

Re: Usage of Data Access Object and Entity beans

Posted By:   Viral_Shah  
Posted On:   Tuesday, November 25, 2003 04:29 AM

Hi Tony,



Well, both the designs are valid. I think this is really about the evolution of EJBs and DAO.



DAO provides an easy-to-use, clean interface to the data access. We can use this pattern to encapsulate the JDBC logic attached with the access of a particular data(db/table). Now this can be used from the 'direct' jdbc clients or BMP entity beans, as and when required.



However, with the CMPs taking the lead of the entity bean development - this advantage becomes useless. u dont need direct jdbc code to implement CMPs. So, where do u utilize DAO? DAO's are still useful, where you need a 'fast-lane-reader' sort of code. At some places, EJB-QL of the CMP is simply not sufficient and you would like to use direct jdbc for more controlled operations. Unfortunately, this means that the clients of the data tier (Servlet/Session Bean), need to talk with the entity beans as well as DAOs, depneding upon the operation required. This is where the next pattern for DAO is useful. DAO can provide 'direct-access' methods as well as proxy methods for the CMP beans.. this way the clients of the data tier have to understand one interface only..



so, ultimately it boils down to one thing: are u using BMP or CMP.. and everything else is positioned accordingly :)



regards.
About | Sitemap | Contact