我可以检索实体,但无法保留 WebSphere 7 JPA

发布于 2024-11-19 16:15:59 字数 2354 浏览 4 评论 0原文

我正在处理一个在 NetBeans 中开发的应用程序。它使用单个实体,可以从数据库检索或保留新实体。它使用带有 EclipseLink 的 JPA 2.0。当部署在捆绑的 Glassfish 中时,它可以正常工作。但是,当部署到 WAS 7.0.0.9(已包含 JPA 2.0 补丁)时,我可以检索实体,但无法保留它们。

我在无状态 EJB 3.0 中保留的代码是:

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

我已将日志记录属性设置为 FINEST,因此我可以获得更多详细信息,

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

但我在日志中得到的只是:

[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

服务器日志也没有显示有关此的信息。有什么想法吗?

提前致谢。


解决方案: 这是工作的 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="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>

I am dealing with an application developed in NetBeans. 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2024-11-26 16:15:59

您是否已将 eclipselink 配置为持久性提供程序?默认情况下,WAS 使用自己的持久性提供程序(它包装 OpenJPA)。

配置 WAS 持久性提供程序

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

Configuring WAS Persistence Provider

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文