Hello!
Looking at the Caveatemptor JPA example I didn't understand one thing:
The comment says:
"If this DAO is wired in as a Seam component, Seam injects the right persistence context if a method on this DAO is called."GenericEJB3DAO.java:
Code:
...
// If this DAO is wired in as a Seam component, Seam injects the right persistence context
// if a method on this DAO is called. If the caller is a conversational stateful component,
// the persistence context will be scoped to the conversation, not to the method call.
// You can call this method and set the EntityManager manually, in an integration test.
@PersistenceContext
public void setEntityManager(EntityManager em) {
this.em = em;
}
...
As far as I understand it means that the DAO has to be a Seam component itself. But, if so, why can I use the annotation
@PersistenceContext instead
@In? I thought when the persistence is Seam-managed I had to use the
@In annotation.
Maybe I understood wrong. I wonder what would happens if I have an instance of a DAO with a
@PersistenceContext annotation in a Seam component. Would Seam handle the EntityManager reference or the EJB Container?
Thanks!
Luiz Filipe