0
我的persistence.xml找不到命名的EntityManager無持久性提供商
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="caronteemirJPAprj">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>ERCOLE</non-jta-data-source>
<class>model.Customer</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.OracleDialect"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@172.31.62.61:1521:ERCOLE"/>
<property name="javax.persistence.jdbc.user" value="ELI"/>
<property name="javax.persistence.jdbc.password" value="eli"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
</properties>
</persistence-unit>
</persistence>
@Stateless
public class QueryBean implements Serializable {
/*
*
*/
private static final long serialVersionUID = -7101661704004061600L;
EntityManagerFactory emf = Persistence.createEntityManagerFactory("caronteemirJPAprj");
@PersistenceContext(unitName="caronteemirJPAprj")
private EntityManager em;
public QueryBean(){
em = emf.createEntityManager();
}
public List<Customer> findAll() {
Query query = em.createQuery("Select h from Customer h");
return (List<Customer>) query.getResultList();
}
public static void main(String[] args) {
QueryBean q = new QueryBean();
q.findAll();
}
}