Currently, we are using Spring Boot 2.5.9.

After upgrading to 2.6.3 the Queries start to fail with the following error.

If we remove the @Lock annotation or lock-mode tag from orm.xml file, the error disappears.

Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
    at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1644)
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
    at org.hibernate.query.Query.getResultList(Query.java:165)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:406)
    at com.sun.proxy.$Proxy169.getResultList(Unknown Source)
    at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:128)
    at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:90)
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155)
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143)
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)

Comment From: sbrannen

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

Comment From: sbrannen

This could possibly be due to a change in behavior in Hibernate.

Have you tried upgrading only the Hibernate version when using Spring Boot 2.5.9 in order to rule out changes in Spring Boot or Spring Framework?

Comment From: kp185128

Yes I tried overriding the hibernate-core dependency with the below version, but got the same error.

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>5.6.3.Final</version>
            </dependency>

Comment From: sbrannen

Yes I tried overriding the hibernate-core dependency with the below version, but got the same error.

Spring Boot 5.6.3 uses Hibernate 5.6.4.Final, not 5.6.3.Final (reference docs).

<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.6.3.Final</version> </dependency>

In any case, that is not the proper way to upgrade a dependency (or group of dependencies) in Spring Boot.

To upgrade a dependency in Spring Boot, you need to follow the instructions here. In the appendix, you'll see that the property you need to set is hibernate.version.

Please upgrade your Spring Boot 2.5.9 application to hibernate.version 5.6.4.Final and let us know if the problem persists.

Comment From: kp185128

Hi @sbrannen , I have a different parent pom and am using spring-boot-dependencies as one of the dependency to include all the compatible libraries. Mentioned in https://docs.spring.io/spring-boot/docs/2.6.3/maven-plugin/reference/htmlsingle/#using.import

So I believe I have used the correct way to override it.

Comment From: sbrannen

So I believe I have used the correct way to override it.

OK. In that case, please provide a minimal example project that reproduces the issue -- preferably via a Git repository or ZIP file that we can download and run.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: kp185128

Please find the example link https://github.com/kp185128/Spring-upgrade-2.6.3

Comment From: kp185128

Any update?

Comment From: snicoll

@kp185128 thanks for the sample but it produces a war file with zero instructions on how to deploy it. How are we supposed to deploy this? Against which database? How can we trigger the problem? If you're using Spring Boot, using an in-memory database and a regular jar file would make it so much easier for us to reproduce the problem.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.