aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "dao  bean ??" Watch "dao  bean ??" New topic
Author

dao bean ??

anil bisht
Ranch Hand

Joined: Nov 04, 2000
Posts: 81
hi,
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 ???
TIA
Anil
SAFROLE YUTANI
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.
SAF
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
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:
http://java.sun.com/blueprints/patterns/j2ee_patterns/catalog.html
regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dao bean ??