简体   繁体   English

界面中的 JPA Hibernate Update 查询

[英]JPA Hibernate Update query in interface

The goal is to update entries in a table.目标是更新表中的条目。 Conceptually I need...从概念上讲,我需要...

public interface MessageRepository extends JpaRepository<Message, Long> {
    @Modifying
    @Transactional
    @Query("update Message set isRead = true where receiver = id and isRead = false")
    void markAllAsRead(Long id);

This compiles however when I run it It seems as though the transaction never commits.然而,当我运行它时,它会编译它似乎事务从未提交过。 According to the documentation I need to flush the cache.根据我需要刷新缓存的文档。 This doesn't seem possible with my current setup with what Ive seen here because I do not have a function body.我目前的设置和我在这里看到的一样,这似乎不可能,因为我没有函数体。 I'm trying to fix someone elses' code so I really don't want to refactor the entire thing.我正在尝试修复其他人的代码,所以我真的不想重构整个事情。

您是否尝试过使用以下参数?

@Modifying(flushAutomatically = true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM