gpt4 book ai didi

hibernate - Websphere 找不到我的 Hibernate 管理的 EntityManager

转载 作者:行者123 更新时间:2023-12-04 05:58:30 25 4
gpt4 key购买 nike

我在 Websphere 7 上使用 Hibernate 3.4,Spring 2.5.6

在启动时,我的应用程序似乎在 Hibernate 与 OpenJPA 之间存在问题:

10/02/12 10:41:50:448 GMT] 00000010 LocalEntityMa I org.springframework.orm.jpa.LocalEntityManagerFactoryBean createNativeEntityManagerFactory Building JPA EntityManagerFactory for persistence unit 'mypu'[10/02/12 10:41:50:495 GMT] 00000010 SystemErr     R   WARNING: Found unrecognized persistence provider "org.hibernate.ejb.HibernatePersistence" in place of OpenJPA provider.  This provider's properties will not be used.

... and then a lovely stack trace caused by:

PersistenceProvider [org.apache.openjpa.persistence.PersistenceProviderImpl@6b676b67] did not return an EntityManagerFactory for name 'mypu'

For info, my persistence unit is defined as follows:

<?xml version="1.0" encoding="UTF-8"?>

<persistence 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"
version="1.0">
<persistence-unit name="mypu" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/serviceTrackerDS</jta-data-source>
<class>...my classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<!-- Properties for Hibernate & Derby -->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
<property name="hibernate.default_schema" value="APP"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
</properties>
</persistence-unit>
</persistence>

我不知道如何继续。似乎某处使用了错误的持久性提供程序,但我已在 persistence.xml 中指定了正确的提供程序。我知道 OpenJPA 是 Websphere 7 中的默认持久性管理器,但我想在这里使用 Hibernate。

有什么建议吗?

最佳答案

看来我需要添加一个 jpaVendorAdapter到我的 entityManagerFactory .

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="mypu" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
</bean>

仍在测试,但看起来不错的分辨率。

关于hibernate - Websphere 找不到我的 Hibernate 管理的 EntityManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9226692/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com