/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ejb; import ent.Company; import javax.ejb.EJBException; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; /** * * @author Lee Andrew */ @Stateful public class CompanyBean implements CompanyRemote { @PersistenceContext(unitName = "Postgre") private EntityManager em; public String getResult() { Company company = null; Debug.print("Object created"); try { Debug.print("Accessing database..."); company = new Company(Long.valueOf("1000")); em.persist(company); } catch (Exception ex) { throw new EJBException("error: " + ex.getMessage()); } } }