I am using stateless session beans. My servlet is going to call the stateless session bean and then that bean is going to call the database to get/update the database.
Is it better to have a bean for doing all database operations or to have a class for doing it ???
servlet - > accountEJB - > databaseEJB - > database
servlet - > accountEJB - > database Object(this will be a simple class ) - > database
which one is better ??
ervlet - > accountEJB - >DAOAcess - > database
DAOAcess will contain all your SQL Queries.
Why to use DAOs here ?
I cant seem to understand why not CMP/BMP ?
I have posted a similar question as to where should DAOs be used.Most of the DAOs I have seen in action are single table type objects.
If I do JDBC queries in a DAO ; I need to do my own transaction management.So I can safely say that for
Create/Update/Delete ; I would like to go for CMP/BMP.
For select (which are normally multiple table joins) why not to embedd queries in the session beans cause CMP/BMP finds are expensive ; and I cant again think why would I use DAOs here?
ok to be more clear .
We are using stored procedures.
So in my data_access_object/data_acccess_bean
i am going to pass the stored procedure name and the input parameters. and getting the collection(in my dao i am converting the resultset to a collection)
So whenever my stateless session bean talks to database it takes through my DAO.
So i am bit confused as to use a data access object or to use a bean for that..