带有Hibernate 5.4的WebLogic 12c(12.2.1.4) [英] WebLogic 12c (12.2.1.4) with Hibernate 5.4
问题描述
我有一个使用Hibernate 5.2.18部署在WebLogic 12c(12.2.1.4)上的应用程序. Weblogic 12c文档参考了JPA 2.1兼容性,而Hibernate 5.3+需要JPA 2.2.我可以在启动类路径之前添加JPA 2.2 API并使用Hibernate 5.3+吗?还是暂时应该坚持使用Hibernate 5.2?
I have an application deployed on WebLogic 12c (12.2.1.4) using Hibernate 5.2.18. Weblogic 12c doc references JPA 2.1 compatibility and Hibernate 5.3+ requires JPA 2.2. Can I prepend the JPA 2.2 API to my startup classpath and use Hibernate 5.3+ or should I stick with Hibernate 5.2 for the time being?
推荐答案
是的,此配置是可能的.
Yes, this configuration is possible.
为避免与WebLogic内置JPA功能发生冲突,您应该执行以下操作:
To avoid conflicts with WebLogic built-in JPA capabilities you should do the following:
- 根据此
在完整的Java EE环境中,请考虑从JNDI获得您的
EntityManagerFactory
.或者,在LocalContainerEntityManagerFactoryBean
定义上指定一个自定义persistenceXmlLocation
(例如,META-INF/my-persistence.xml),并在应用程序jar文件中仅包含具有该名称的描述符.由于Java EE服务器仅查找默认的META-INF/persistence.xml
文件,因此它会忽略此类自定义持久性单元,因此避免了与Spring预先驱动的JPA设置产生冲突.
In a full Java EE environment, consider obtaining your
EntityManagerFactory
from JNDI. Alternatively, specify a custompersistenceXmlLocation
on yourLocalContainerEntityManagerFactoryBean
definition (for example, META-INF/my-persistence.xml) and include only a descriptor with that name in your application jar files. Because the Java EE server looks only for defaultMETA-INF/persistence.xml
files, it ignores such custom persistence units and, hence, avoids conflicts with a Spring-driven JPA setup upfront.
您可以在spring上下文配置中使用类似的内容.
You can use something like this in the spring context config.
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<!-- ... -->
<jee:jndi-lookup id="DS" jndi-name="appDS" />
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:META-INF/app-persistence.xml" />
<property name="dataSource" ref="DS" />
</bean>
<!-- ... -->
</beans>
- 根据此
要配置
FilteringClassLoader
以指定从应用程序中加载某个软件包,请在weblogic-application.xml
中添加一个prefer-application-packages
描述符元素,该元素详细说明要从该应用程序中加载的软件包列表.
To configure the
FilteringClassLoader
to specify that a certain package is loaded from an application, add aprefer-application-packages
descriptor element toweblogic-application.xml
which details the list of packages to be loaded from the application.
您应将以下代码段添加到META-INF/weblogic-application.xml
You should add the following snippet to your META-INF/weblogic-application.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<prefer-application-packages>
<!-- ... -->
<package-name>javax.persistence.*</package-name>
</prefer-application-packages>
</weblogic-application>
这篇关于带有Hibernate 5.4的WebLogic 12c(12.2.1.4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!