Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dao bean ??

 
anil bisht
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic