Issue
I'm currently working on an older Spring project (not Spring Boot). This uses the spring-boot-dependencies as the parent BOM. A migration to SpringBoot is planned for the near future. We are currently still using the dependencies from version 2.6.7. I would now like to upgrade to 2.7.0.
I have problems with my own queries in a JPA repository. The query is a JPQL query that only executes a select:
@Query("select x from y where y.date = (select max(tmp.date) from y tmp where y.thingId = tmp.thingId)")
When running the query, "No transactional EntityManager available" is thrown. If I annotate the repository or method with a Transactional-annotation, the query runs. However, I am surprised that this is now necessary? Previously, the query could be executed without Transactional annotation. Has there been a change here? I don´t find any information in the release note.
Edit: i have create a abstract github-project with the issue: https://github.com/helo-trix/72520519
Solution
This is a bug that has been fixed here https://github.com/spring-projects/spring-data-jpa/pull/2542
upgrading to springboot 2.7.2 will fix your problem
Answered By - Minsoo Cheong
Answer Checked By - Katrina (JavaFixing Volunteer)