【问题标题】:Why spring Data JPA does select before update & delete为什么 Spring Data JPA 在更新和删除之前选择
【发布时间】:2020-06-03 15:36:09
【问题描述】:

我现在每次执行更新或删除 Spring 数据 JPA 在运行实际查询之前选择时都使用 Spring 数据 JPA。

@Modifying
@Query("update Device d set d.latestDevice = ?1 where d.senderId = ?2")
@Transactional(readOnly = false)
int updateLatestDevice(Device newDevice, Integer senderId);

@Modifying
@Transactional(readOnly = false)
int deleteById(Integer deviceId);

我找不到这种情况的确切答案。

【问题讨论】:

  • 这能回答你的问题吗? Hibernate select before update
  • 上一个问题只讨论了如何禁用选择。我正在寻找在更新和删除之前触发选择的原因?

标签: spring-boot hibernate spring-data-jpa


【解决方案1】:

我不确定更新是否会触发选择。

删除操作会触发事件,这些事件将删除的实体作为有效负载,因此需要加载它们。

【讨论】:

    猜你喜欢
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-11-03
    • 1970-01-01
    • 2013-05-14
    • 2019-05-25
    • 2021-04-02
    • 2019-12-20
    相关资源
    最近更新 更多