Hi,
i am currently writing a portal where portlets(modules) need access to the persistence layer, but the use cases of a portlet can not be foreknown.
Because of this i can not use Seam, because Seam uses a (Stateful)Bean per Use Case which i can not foreknown. So i need somethink like a facade where i can give over persistent (not detached) entity beans to the portlets.
In caveatemptor i found the DAO-Pattern which is really nice. I implement the DAOs (like UserDAO, GroupDAO) as Statefull SessionBeans (SFSB) and the DAOFactory looks the up via JNDI.
This works nice but my unit of work is not atomic anymore, because each DAO SFSB has it's own ExentedEntityManager. The conclusion is that i need
something like a Context (Application, Session, Request, Event, ...) in Seam.
Unfortunatelly it is not possible (ends up in "horrible exception or undefiend behavior" in JBoss EJB3.0 Forum) to give out the EntityManager of a SFSB which includes share the EntityManager between SFSBs. The possibility to inject every DAO SFSB in something like a Context SFSB to share the lifetime and the entityManager is an antipattern, because for each new Context ALL DAOs have to be created which is really inefficient.
I also read "Chapter 1.2.4. Persistence context propagation" of Hibernate EntityManager documentation, but i didn't get any additional ideas about the problematic.
An other alternative would be something like a command pattern. I would have a Context SFSB which is the command executor and the DAO SFSB only creates Command Implementations and send it to the Executor.
So any idea how to solve my problem?
Regards
Peter
|