0 Replies Latest reply on Mar 27, 2006 4:50 AM by Petra Tobolikova

    @PersistenceUnit on SessionBean class

    Petra Tobolikova Newbie

      Hi, excuse my (maybe) silly question, I'm relatively new to EJBs.

      When I use code like this (example from the EJB3.0 specification):

      @PersistenceUnit(
      name=?persistence/InventoryAppDB?,
      unitName=?InventoryManagement?
      )
      @Stateless
      public class InventoryManagerBean implements InventoryManager {
      @Resource SessionContext ctx;

      public void updateInventory(...) {
      ...
      javax.persistence.EntityManagerFactory emf =
      (javax.persistence.EntityManagerFactory)
      ctx.lookup("persistence/InventoryAppDB");
      javax.persistence.EntityManager em = emf.getEntityManager();
      ...
      }
      }

      it doesn't work by now and I heard it's a bug and should be corrected in another version of JBoss AS..

      WHAT I'd like to know is whether I could register the "persistence/InventoryAppDB? on one SessionBean class and call the
      ctx.lookup("persistence/InventoryAppDB");
      in another bean of different SessionBean class.. Will the environment still be visible?