JPA EntityManager详解

1.获得EntityManager对象 

两种方式:1 @PersistenceContex注入 2 JNDI获得 


private EntityManager em;


@PersistenceContext
public void setEntityManager(EntityManager em) {
this.em = em;
}


2.配置(这是用ant)









 





















META-INF配置


xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

WEB-INF/lib/crmbase.jar


你可能感兴趣的:(java)