【发布时间】:2014-10-21 04:38:36
【问题描述】:
我是 JPA 的新手。我正在使用 maven、eclipselink 2.0 和 jpa 2.0。我已经使用数据库连接创建了实体。这是我的 persistence.xml
<?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="certifications" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/com/ni/ds_edata_soa_nontx</jta-data-source>
<class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStg</class>
<class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStgPK</class>
<class>com.ni.apps.engineering.certification.entities.NicdsCliUpMapping</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.password" value="soa_user"/>
<property name="javax.persistence.jdbc.user" value="soa_user"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
这是我在尝试运行应用程序时遇到的错误。
detailMessage "异常 [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException\r\n内部异常: java.sql.SQLException: java.sql。 SQLException: 用户: NI,验证失败。\r\n错误代码: 0" (id=114)
如您所见,在我的坚持中没有什么叫做“NI”。唯一称为 NI 的是我从中提取表以创建实体的模式。 JTA 数据源是我的 weblogic 中内容的精确副本。
有什么想法吗?
--编辑-- 这就是我获得 EntityManager 的方式
private EntityManagerFactory emf;
protected EntityManager getEntityManager(){
if(emf == null){
emf = Persistence.createEntityManagerFactory("certifications");
}
return emf.createEntityManager(); //This is where it fails
}
【问题讨论】:
标签: jpa eclipselink