EJB design: Design Patterns to Access Data(DAO) objects.

  1. Design Patterns to Access Data(DAO) objects. (6 messages)

    To access database we use simple java classes called as xxxDAO.java. Where we open the connection, write the database related queries and return the results(Result set and Out parameter) to Session Beans, and close the connection. I was thinking to write one pattern where we can open the connection and access the corresponding DAO class and the pass the results and close the connection.

    So in this way all Session Beans can invoke only one class, pass the required parameters and get the result.

    Let me know if this makes sense to you all. Or there is any better approach.
  2. how is this any different than the DAO pattern.
    one ?.
    U open a Connection in the session bean....u say ?
    think about the portabilty issues.If ur DB changes then u will have to recode the getConnection part fro DB.So if this is in the session bean then u will have to recomplie AND DEPLOY the bean again.
  3. I do not want to put the connection in session bean. But write one facade and get the connection there and then pass it DAO's. So all session beans will call only once class and get the result.
  4. I forgot to mention one point here, we use user created result set which is basically a replica of java.sql.Result Set. So not to worry about the connection after returning the result set.
  5. If i am correct, You want to make a geeric class instead of class for each Bean.

    In my EJB application i am using such 'Generic SQL Class' which can generate the SQL dynamically. Also it is used throughout my EJB application.

    -Viren Jasani.
  6. We are not writing any SQL coding except calling stored procedures and getting the result.

    But yes, I want to make a generic class for calling DAO's. So the session bean will call only one object and that is the interface to all DAO's.
  7. .. Soni
    what about deployment issues..How will u package this class?