2 Replies Latest reply on Jan 12, 2011 7:52 AM by Luis Fernando Planella Gonzalez

    Transactions and stateful - stateless beans interaction

    Luis Fernando Planella Gonzalez Newbie


      I'm using JBoss 6.0.0.

      This is the first time I'm using a stateful bean, but I swear I have googled a lot and haven't found an specific answer

      I have a stateful bean with an EntityManager injected with (PersistenceContextType.TRANSACTION).

      From this bean, I invoke an stateless bean, which also has an injected EntityManager, and the method returns an entity.

      I was expecting a single transaction to happen, and that the returned entity would be attached.

      However, this is not the case, as I try to access a collection on that entity, and a LazyInitializationException is thrown.

      How to make sure that the same transaction and entity manager is used on both beans?

      Thanks a lot.