Hibernate Java 10
我将应用程序从Java 8迁移到了Java10。但是,当我尝试在数据库中存储某些内容时,我看到以下异常
Caused by: javax.persistence.RollbackException: Error while committing the transaction at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:77) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) ~[spring-orm-4.3.18.RELEASE.jar:4.3.18.RELEASE]
... 91 more
Caused by: org.hibernate.AssertionFailure: Exception releasing cache locks
at org.hibernate.engine.spi.ActionQueue$AfterTransactionCompletionProcessQueue.afterTransactionCompletion(ActionQueue.java:990) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.engine.spi.ActionQueue.afterTransactionCompletion(ActionQueue.java:513) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.internal.SessionImpl.afterTransactionCompletion(SessionImpl.java:2501) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterTransactionCompletion(JdbcCoordinatorImpl.java:479) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.afterCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:198) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$400(JdbcResourceLocalTransactionCoordinatorImpl.java:39) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:273) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:98) ~[hibernate-core-5.3.2.Final.jar:5.3.2.Final]
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517) ~[spring-orm-4.3.18.RELEASE.jar:4.3.18.RELEASE]
... 91 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private jdk.internal.reflect.ConstructorAccessorImpl jdk.internal.reflect.DelegatingConstructorAccessorImpl.delegate accessible: module java.base does not "opens jdk.internal.reflect" to unnamed module @55283c54
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337) ~[?:?]
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281) ~[?:?]
at java.lang.reflect.Field.checkCanSetAccessible(Field.java:176) ~[?:?]
at java.lang.reflect.Field.setAccessible(Field.java:170) ~[?:?]
我使用以下依赖项
<spring.version>4.3.18.RELEASE</spring.version><spring-boot.version>1.5.14.RELEASE</spring-boot.version>
<hibernate-core.version>5.3.2.Final</hibernate-core.version>
<java.version>1.10</java.version>
回答:
这是根本原因
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private jdk.internal.reflect.ConstructorAccessorImpl jdk.internal.reflect.DelegatingConstructorAccessorImpl.delegate accessible: module java.base does not "opens jdk.internal.reflect" to unnamed module @55283c54
Java 10具有模块的概念,首先public
不再是“公开”的,并且反射也不是那么强大。
您可以按照@RobertHume的建议使用JVM标志,但实际上您需要迁移到支持Java9 / 10(如果有)的较新的Hibernate版本。
另请检查此链接https://www.sitepoint.com/reflection-vs-encapsulation-in-the-java-
module-system/#commandlineescapehatches以获取有关建议的JVM标志的更多详细信息
以上是 Hibernate Java 10 的全部内容, 来源链接: utcz.com/qa/403847.html