@javax.persistence.Entity public class CustomerEntity implements java.io.Serializable { private String id; private String firstname; private String lastname; //... } |
public class
CustomerDAOImpl implements CustomerDAO { @javax.transaction.PersistenceContext(unitName="customer") EntityManager em; } |
<?xml version="1.0"
encoding="UTF-8"?> <persistence> <persistence-unit name="customer"> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit> </persistence> |
<?xml version="1.0"
encoding="UTF-8"?> <persistence> <persistence-unit name="customer"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/DefaultDS</jta-data-source> <jar>customer-jpa.jar</jar> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PointbaseDialect" /> <property name="hibernate.transaction.manager_lookup_class" value="jpahibernate.CubaTransactionManagerLookup" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit> </persistence> |
@Stateless(name="CustomerDAO") public class CustomerDAOImpl implements CustomerDAO { @PersistenceContext(unitName="customer") public EntityManager em; public CustomerEntity find(String id) { return em.find(CustomerEntity.class, id); } public void create(CustomerEntity entity) { em.persist(entity); } } |
Home | Introduction | Javadoc |