java - SpringBoot v2.7.0 - Select-Query without transactional-annotation => No transactional EntityManager available |现在有了 github-example

标签 java spring spring-boot

我目前正在处理一个较旧的 Spring 项目(不是 Spring Boot)。这使用 spring-boot-dependencies 作为父 BOM。计划在不久的将来迁移到 SpringBoot。我们目前仍在使用 2.6.7 版本的依赖项。我现在想升级到 2.7.0。

我自己在 JPA 存储库中的查询有问题。该查询是一个仅执行选择的 JPQL 查询: @Query("select x from y where y.date = (select max(tmp.date) from y tmp where y.thingId = tmp.thingId)")

运行查询时,抛出“没有可用的事务性 EntityManager”。如果我使用事务注释对存储库或方法进行注释,查询就会运行。但是,我很奇怪现在有这个必要吗?以前,可以在没有事务注释的情况下执行查询。这里有变化吗?我在发行说明中找不到任何信息。


编辑:我创建了一个带有问题的抽象 github 项目:https://github.com/helo-trix/72520519

最佳答案

这是一个已在此处修复的错误 https://github.com/spring-projects/spring-data-jpa/pull/2542

升级到 springboot 2.7.2 将解决您的问题

关于java - SpringBoot v2.7.0 - Select-Query without transactional-annotation => No transactional EntityManager available |现在有了 github-example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72520519/

相关文章:

java - log4.xml 中用于访问 java 系统属性的表达式语言是什么?

java - 改进了使用 Jackson 将嵌套 JSON 对象的 boolean 值转换为 Map 的方法

css - 在 spring-boot 应用程序中获取用于下载字体文件 (ttf) 的弹出窗口

java - Spring-boot 中 ConditionalOnBean 的意外行为

java - 引用未知实体 : java. lang.Integer

java - 通过 TLS/SSL 将 RESTHeart 连接到 MongoDB

java - 如何避免java中自引用类型安全接口(interface)的参数类型警告?

java - Spring Cron 表达式 : 10 minutes after every hour

java - Spring Boot 的多重构造函数注入(inject)歧义

java - 使用Spring 3.0的MultipartHttpServletRequest时的请求大小限制