Here's my question:
I have some Stateless Session Bean classes. This is a very simple applications which lets users leave their names and phone numbers so a salesman can contact them later. To do this, I have set up an Inquiry entity bean.
I also have a stateless session bean called InquiryManagerBean. There is an InquiryManagerBean interface like this:
@Local public interface InquiryManagerBean { /** Create a new persistent Inquiry instance */ public Inquiry create(Inquiry toCreate); }
@Stateless public class InquiryManagerBeanLocal implements InquiryManagerBean { @PersistenceContext EntityManager entityManager; /** Creates a new instance of InquiryManagerBeanLocal */ public InquiryManagerBeanLocal() { } public Inquiry create(Inquiry toCreate) { if(entityManager == null) { logger.severe("No entity manager was found in " + "this persistence context! Nothing will work."); return null; } if(toCreate == null) return null; entityManager.persist(toCreate); return toCreate; } }
InitalContext context = new InitialContext(); InquiryManagerBean inquiryManagerBean = (InquiryManagerBean) context.lookup("MyApplicationName/InquiryManagerBeanLocal/local");