Hi... design question.
When using a SessionBean and some DAO classes, should i then inject EntityManager in all dao classes or pass it as a variable. ?
My SessionBean is injecting the EntityManager. I have read different opinions about this.
If I use a transaction started in my SessionBean, I would guess I should use the same EntityManager in that transaction. ? Hence passing it to the DAO classes. ?
Or can the container keep track of it if I inject my DAO classes and inject the EntityManager in the DAO class, and do not pass it ??
I would keep DAO classes clean and did not use EntityManager here.
If you use EJB3 and JPA I would use the JPA classes, or if not wanted you may create the DAO inside the SLSB or JPA class.