简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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