开发者

I can retrieve entities but I can't persist WebSphere 7 JPA

开发者 https://www.devze.com 2023-03-19 07:12 出处:网络
I am dealing with an application developed in Ne开发者_如何学运维tBeans. It uses a single entity and can either retrieve from DB or persist new entities. It uses JPA 2.0 w/ EclipseLink. When deployed

I am dealing with an application developed in Ne开发者_如何学运维tBeans. It uses a single entity and can either retrieve from DB or persist new entities. It uses JPA 2.0 w/ EclipseLink. When deployed in bundled Glassfish, it works correctly. However, when deploying into WAS 7.0.0.9 (already includes the JPA 2.0 patch), I can retrieve entities, but I can't persist them.

My code to persist, within a Stateless EJB 3.0 is:

public void create(MyEntity entity) {
        getEntityManager().persist(entity);
}

I've set the logging property to FINEST, so I can get more detail,

<property name="eclipselink.logging.level" value="FINEST"/>

but all I get in the log is:

[EL Finer]: 2011-07-11 17:02:59.813--UnitOfWork(1634296169)--Thread(Thread[WebContainer : 9,5,main])--initialize identitymaps
[EL Finer]: 2011-07-11 17:02:59.815--ServerSession(833630640)--Thread(Thread[WebContainer : 9,5,main])--client acquired
[EL Finest]: 2011-07-11 17:02:59.815--UnitOfWork(137562163)--Thread(Thread[WebContainer : 9,5,main])--PERSIST operation called on: PU_TEST.
[EL Finer]: 2011-07-11 17:02:59.816--UnitOfWork(137562163)--Thread(Thread[WebContainer : 9,5,main])--initialize identitymaps

The server logs show no info about this either. Any ideas?

Thanks in advance.

SOLUTION: This is the working persistence.xml file

<?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="fonacotCap" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/fonacotCap</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-server" value="WebSphere_7"/>
            <property name="eclipselink.target-database" value="Informix"/> 
            <property name="eclipselink.weaving" value="true"/>** 
            <property name="eclipselink.ddl-generation" value="create-tables"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
            <property name="eclipselink.logging.file" value="/opt/apps/libs/persistence.log"/>
        </properties>
    </persistence-unit> </persistence>


Have you configured eclipselink as your persistence provider? By default WAS uses its own persistence provider (which wraps OpenJPA).

Configuring WAS Persistence Provider

0

精彩评论

暂无评论...
验证码 换一张
取 消