File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes EJB Stateless Session Bean with DAOs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB Stateless Session Bean with DAOs" Watch "EJB Stateless Session Bean with DAOs" New topic

EJB Stateless Session Bean with DAOs

Andrew Burger

Joined: Mar 22, 2007
Posts: 3
I am wondering the pros and cons of each way to implement a Stateless Session Bean with DAO objects. If there is a another way then these that is better, please let me know.


[ March 22, 2007: Message edited by: Andrew Burger ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

My recommendation is always to not do stuff in the stateless session bean directly. Add another layer between your EJBs and the DOA layer. Make POJO classes that actually implement you business logic, then have your EJB create an instance of these POJO Service classes and call a method in it. Then in that POJO class is where you create instances of your DAO through a DAOFactory.

This allows the reuse of the service POJO Use Case object for other services that might need the same code, and takes out the need for these other services to do a local or remote lookup of the EJB that has that code. Plus you can test these POJOs outside of the container.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: EJB Stateless Session Bean with DAOs
It's not a secret anymore!