EJB programming & troubleshooting: How to handle business logic inside a session bean

  1. I had a question on how to use a session bean correctly. I have a process where I need to access the database, perform some calculations and run many business rules. Should I have DAOs for data access, util classes for calculations and validations and then create these objects when the session bean is created and cache them so that I could reuse them throughout. Is this the right approach or is there a better way to handle it.

  2. Its always better to separate out your DB layer processing in a DAO, so that whereever necessary you can use it. Session bean (Use SessionFacade pattern here) will just call the DAO and gets the related objects. If possible use value objects also.