dcsimg
DAO
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   guru_prasanth
Posted On:   Tuesday, July 1, 2003 09:05 PM

in a session facade pattern when exactly to use dao and when to use entity bean(IN WHICH CONTEXT).it's said that dao is used in order to make data acess independent of the medium whether it uses dbms ,ldap or any legacy system.the same thing could be achived by using datasource object(in dao object also uses datasource object for acessing ldap and legacy system)in entity bean.iam beginner in dao please correct me if iam wrong.

Re: DAO

Posted By:   Matan_Amir  
Posted On:   Thursday, July 24, 2003 01:35 AM

Hi Guru,


You are right in saying both DAO and datasource objects can achieve the same outcome (data de-coupling) but I think DAO objects are used to provide the data independence in an object oriented manner. If you have DAO objects for specific data sources that inherit from the same interface for example, they can be changed on the fly, or new DAO implementations can be added easily (the factory pattern comes to mind). Like an OracleUserDAO, XMLUserDAO, MySqlUserDAO, 3rdPartyAppUserDAO, etc. all inheriting from IUserDAO.



You are also free to implement each DAO implementation differently and don't need to rely on a datasource object - let's say for file system access.



The question of when to use DAO and when to use entity beans is a tough one. I personally use DAO objects when I don't plan to use EJB at all. I find it a useful pattern, especially when i know the data layer will only be accessed locally (no remote interfaces) and I don't need container managed data persistance.


Hope that helps,

Matan
About | Sitemap | Contact