J2EE DAO Pattern

From: Chuck (cmedcoff_at_hotmail.com)
Date: 12/18/04


Date: Sat, 18 Dec 2004 10:47:20 -0500

I've recently read the J2EE DAO Pattern on Sun's website at
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html.
There is use of GOF patterns here, but there is at least two things that I
do not like about this pattern or at least the code example of it. The
first thing is that the DAOFactory defines a few public static final int's
for parmeterizing the getDAOFactory() method. This seem to some extent
violate OCP. DAOFactory's pulic interface is note closed if new underlying
datasources must be defined. The second thing that I don't like comes from
the standpoint of testing. The DAOFactory's getDAOFactory() method
restricts DAO's use only a certain particular data source at one time. This
would not allow one to use combinations say a of an ORACLE DAO for one set
of domain objects and a testing sub for another if one so desired.

As an alternative it seems that use of some sort of DAORegistry where an
applications "main" could populate the registry with any combinations of
data source DAO's would allow a bit more flexibility. One drawback to this
would be that unless DAORegistry client's called a clone method on DAOs in
the registry, the clients would have to share DAO objects. Perhaps not a
problem if the DAO's are stateless/threadsafe.

Comments?



Relevant Pages

  • Re: dao questions
    ... > A lot of people recommend using the dao pattern for data access because it ... > makes it easy to change persistance strategy and abstracts away the ... logic _outside_ the dao. ... pattern or in your delegates. ...
    (comp.lang.java.programmer)
  • Factory/Proxy question...
    ... I'm currently using a Factory pattern to create DAO objects... ... But I've also implemented a Proxy pattern which will try and delay ... class ProxiedXmlPersonDao ...
    (comp.software.patterns)
  • Re: Runtime Error 3706
    ... > person is running Windows XP SP2. ... So I ran the MDAC Utility Component Checker ... > in the Registry and still no luck. ... There is a situation if you are using DAO and a DAO Control - the DAO360.Dll ...
    (microsoft.public.vb.general.discussion)
  • Re: Registry entries and Virus Scanners
    ... > in DAO with ODBC is to make sure there is an entry in the ODBC.ini ... This would allow you to not have to setup a DSN connection at all, ... intrusive -- you aren't writing to the user's registry, ... machines. ...
    (microsoft.public.vb.general.discussion)
  • Re: Accessing mdb file via VB code
    ... installable ISAM" when a connection to my database was attempted on ... I am not afraid to edit the registry (Well I kinda sorta am but still can ... Are you using the ADO or DAO data access libraries? ...
    (microsoft.public.vb.general.discussion)