-
1. Re: ejb3 best practice question
mazz Mar 28, 2006 9:28 AM (in response to kh2ouija)I think you will want to investigate JBoss SEAM. It probably will answer all your questions regarding how to do what you want to do.
http://www.jboss.com/products/seam -
2. Re: ejb3 best practice question
kh2ouija Mar 30, 2006 5:07 AM (in response to kh2ouija)Investigating Seam, I now have another "how would you do it" question. I think it's silly, but anyway:
So far, I've been using the GenericDAO pattern and I want to reuse it with Seam. My GenericDAOBean's EntityManager is not EXTENDED type, and my *DAOBeans are all Stateless; this has been OK so far. But in the Seam reference, some examples (like the MessageListBean from the tutorial) is stateful and uses an extended EntityManager; I suppose using a stateless DAO bean inside it instead of the EntityManager is therefore not an option. I could just make all the *DAOBeans stateful but I'm not sure it's the right thing to do.
So, how can I reuse the DAO beans inside the Seam session beans? -
3. Re: ejb3 best practice question
epbernard Mar 30, 2006 12:23 PM (in response to kh2ouija)if your SFSB EXTENDED use a SLSB, the same persistence context is propagated, if I remember.
-
4. Re: ejb3 best practice question
kh2ouija Mar 31, 2006 4:49 AM (in response to kh2ouija)Let me understand this...
In the Seam tutorial, the MessageListBean is stateful and uses an extended EntityManager. Would it be OK to use stateless DAO beans instead of that EntityManager? (those DAOs use an EntityManager which isn't extended) -
5. Re: ejb3 best practice question
kh2ouija Apr 1, 2006 9:15 AM (in response to kh2ouija)that is, instead of
@PersistenceContext(type=EXTENDED) private EntityManager em; @Factory("messages") public void findMessages() { messages = em.createQuery("from Message msg order by msg.datetime desc").getResultList(); }
I'd have@EJB private MessageDAO messageDAO; @Factory("messages") public void findMessages() { messages = messageDAO.findAll(); }
where the MessageDAOBean is stateless and uses a non-extended EntityManager.
Is this the same thing? do I have to make the MessageDAOBean stateful too? -
6. Re: ejb3 best practice question
epbernard Apr 3, 2006 5:51 AM (in response to kh2ouija)@PersistenceContext(type=EXTENDED) private EntityManager em; @EJB private MessageDAO messageDAO; @Factory("messages") public void findMessages() { messages = messageDAO.findAll(); }
-
7. Re: ejb3 best practice question
kh2ouija Apr 10, 2006 5:23 AM (in response to kh2ouija)Emmanuel, sorry but I don't understand your last message, can you please explain? I intend not to use the EntityManager in that bean, only the DAOs.