1 Reply Latest reply on Apr 8, 2013 3:32 PM by Wolf-Dieter Fink

    Injecting EntityManager or passing it

    klind Newbie

      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 ??