英文:
How can I set transactions mandatory for read operations in Quarkus?
问题
I recently discovered that I can perform read operations using a Panache repository during a QuarkusTest
without an active transaction. This behavior took me by surprise, and it also resulted in incorrect data being returned (possibly due to caching). As soon as I put an active transaction around the test, everything works as expected. Unfortunately, I couldn't reproduce the issue with a reproducer. I attempted to find a configuration option to enforce a transaction for read operations, but I was unable to locate a suitable setting.
How can I configure Quarkus with Hibernate ORM to make transactions mandatory, even for read operations?
It seems that setting the TransactionRequirement
to STRICT
is not a viable solution for me, as it would prevent the Liquibase migration from executing.
英文:
I recently discovered that I can perform read operations using a Panache repository during a QuarkusTest
without an active transaction. This behavior took me by surprise, and it also resulted in incorrect data being returned (possibly due to caching). As soon as I put an active transaction around the test, everything works as expected. Unfortunately, I couldn't reproduce the issue with a reproducer. I attempted to find a configuration option to enforce a transaction for read operations, but I was unable to locate a suitable setting.
How can I configure Quarkus with Hibernate ORM to make transactions mandatory, even for read operations?
It seems that setting the TransactionRequirement
to STRICT
is not a viable solution for me, as it would prevent the Liquibase migration from executing.
答案1
得分: 1
可以在事务外部访问一个只读的实体管理器/会话。在我看来,这是非常值得怀疑的行为,但实际上有些人确实依赖于这一点。
据我所知,没有内置的方法来禁用这个,但你可以提出一个配置属性的建议在此处提出一个问题。
英文:
Yes, you can access a read-only entity manager / session outside of transactions. That's (very) questionable behavior in my opinion, but some people actually rely on that.
There is no built-in way to disable that as far as I know, but you can certainly open an issue to suggest a configuration property.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论