This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

dao bean ??  RSS feed

 
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
 
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
 
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.
 
Hold that thought. Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!