Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes dao  bean ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "dao  bean ??" Watch "dao  bean ??" New topic

dao bean ??

anil bisht
Ranch Hand

Joined: Nov 04, 2000
Posts: 81
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 ???
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
The preferred method is to encapsulate your business logic in the session bean, and encapsulate persistence logic in a data access object, which the session bean invokes to update and retrieve data to and from the database.
Of course, you can code your session bean to access the database directly, but by introducing an additional layer, namely, a data access layer where all DAO objects lay, you are creating a clear separation of responsibility among your enterprise components. Your code will be easier to maintain and update in the future.
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
If the server you�re using supports ejb2.0 specs you should consider using cmp with local interfaces instead of DAOS as sun j2ee design patterns catalog suggests.
Take a look at:
I agree. Here's the link:
subject: dao bean ??
It's not a secret anymore!