DAO pattern???

Discussions

General J2EE: DAO pattern???

  1. DAO pattern??? (2 messages)

    Just after some help here really, I would like to know if I have the right idea about the DAO pattern. The application I am working on is using a stateless session bean as a Transfer Object Assembler this will act as a session facade, I am also using the DAO pattern rather than entity ejb's as my database interaction method, as the DAO pattern is a non ejb implementation I believe it therefore will not be aware of the ejb-jar.xml, so how have do I manage the configuration of non ejb classes.

    Secondly is there any problems you are aware of with using ejb hosted classes and non ejb's?

    Any assistance given will be gratefully received.

    Threaded Messages (2)

  2. DAO pattern???[ Go to top ]

    You do have the right idea. A DAO is simply a POJO that makes JDBC calls to a database. You're correct that the DAO is not aware of ejb-jar.xml. The only thing you really need to do to configure the DAO is to supply the data source's JNDI name. You can specify this in web.xml, or a separate configuration file, or you can hard-code it (not recommended, but it works).

    Also you'll need of course the table names and the SQL queries you'll run. As with the JNDI name, you can hard-code these or put them in a configuration file. You could always put it in a .properties file in WEB-INF/classes and read it from there.
  3. DAO pattern???[ Go to top ]

    Thanks for the help.

    I am using Websphere 5 Enterprise Developer and one of my colleguges has told me that I can register the JNDI names of POJO's using the Universal Test Client? not sure if this is correct but I will give it a try.
    Thanks