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.
how is this any different than the DAO pattern.
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.
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.
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.
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.
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.
what about deployment issues..How will u package this class?