gpt4 book ai didi

java - Hibernate版本支持Oracle12cDialect和JPA 2.0

转载 作者:行者123 更新时间:2023-11-30 05:45:24 25 4
gpt4 key购买 nike

我将应用程序(Spring + Hibernate + JPA)部署到 Websphere 应用程序服务器,并且应用程序连接到数据库版本 Oracle 12c。

为了支持 Oracle 12c DB,我需要 Oracle12c Dialect 并且 Websphere 应用程序服务器(8.5.5)支持 JPA 2.0。

我看到 Hibernate 版本 > 5 仅提供 Oracle12cDialect,不提供 JPA 2.0,而是提供 (hibernate-jpa-2.1-api-1.0.0.Final.jar)

V3.5至V4.2支持JPA 2.0(但这些版本不适用于Oracle12cDialect)

当我使用 hibernate-entitymanager.5.0.7.Final.jar 时,我在服务调用期间收到以下错误。

错误:

Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
at javax.persistence.Persistence$1.isLoaded(Persistence.java:110) ~[hibernate-jpa-2.1-api-1.0.0.Final.jar:1.0.0.Final]
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:57) ~[hibernate-validator-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:130) ~[hibernate-validator-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:46) ~[hibernate-validator-4.3.0.Final.jar:4.3.0.Final]
at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1221) ~[hibernate-validator-4.3.0.Final.jar:4.3.0.Final

如果我尝试保留应用程序提供的 hibernate-jpa-2.1-api-1.0.0.Final.jar 范围,它会创建以下问题作为 AttributeConverter该类在 Websphere JPA 2.0 中不可用

ERROR o.s.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax.persistence.AttributeConverter
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE]
Caused by: java.lang.NoClassDefFoundError: javax.persistence.AttributeConverter
at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127) ~[hibernate-core-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135) ~[hibernate-core-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:185) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:160) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:50) ~[hibernate-entitymanager-5.0.7.Final.jar:5.0.7.Final]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:287) ~[spring-orm-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) ~[spring-orm-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ~[spring-beans-3.1.3.RELEASE.jar:3.1.3.RELEASE]
... 69 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.persistence.AttributeConverter
at java.net.URLClassLoader.findClass(URLClassLoader.java:600) ~[na:1.7.0]
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:240) ~[bootstrap.jar:WAS855.SERV1 [cf051507.01]]
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:941) ~[na:1.7.0]
at java.lang.ClassLoader.loadClass(ClassLoader.java:876) ~[na:1.7.0]
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:133) ~[bootstrap.jar:WAS855.SERV1 [cf051507.01]]
at java.lang.ClassLoader.loadClass(ClassLoader.java:846) ~[na:1.7.0]
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf051507.01]]
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf051507.01]]
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:617) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf051507.01]]
at java.lang.ClassLoader.loadClass(ClassLoader.java:846) ~[na:1.7.0]
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:617) ~[com.ibm.ws.runtime.jar:WAS855.SERV1 [cf051507.01]]
at java.lang.ClassLoader.loadClass(ClassLoader.java:846) ~[na:1.7.0]
... 81 common frames omitted

如果我使用Hibernate版本支持JPA 2.0,那么只需要使用Oracle10gDialect。

hibernate 和 webSphere 成员有什么想法吗?

最佳答案

此问题没有解决方案,您只能:

  • 将您的 Websphere 版本升级到 WAS 9.0(当然,这是一个简单的任务:))
  • 继续使用 Oracle10gDialect,除了版本特定的详细信息(但我从未在简单的 JPA 使用中遇到任何问题),它与 配合得很好Oracle 12

附注有一个IBM note关于在 WAS 8.5.5 上启用 JPA 2.1,但说实话,这种努力没有得到返回(不再有容器管理持久性?不,谢谢)。

关于java - Hibernate版本支持Oracle12cDialect和JPA 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54931357/

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