Spring boot JPA自定义查询从多个表中删除

Spring boot JPA自定义查询从多个表中删除,spring-boot,jpa,crud,Spring Boot,Jpa,Crud,我有一个用于从2个表中删除记录的自定义查询,如下所示 @存储库 公共接口RoamingStatusHistoryRepository扩展了JpaRepository{ @查询(“从RoamingStatusHistory中删除rsh,rs在rsh.msisdn=rs.msisdn其中TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'”上的rsh内部连接RoamingStatus rs) 公共列表deleteByDate(); }我假设此查询是本机SQL查询,因

我有一个用于从2个表中删除记录的自定义查询,如下所示

@存储库
公共接口RoamingStatusHistoryRepository扩展了JpaRepository{
@查询(“从RoamingStatusHistory中删除rsh,rs在rsh.msisdn=rs.msisdn其中TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'”上的rsh内部连接RoamingStatus rs)
公共列表deleteByDate();

}
我假设此查询是本机SQL查询,因此必须添加nativeQuery=true

@Repository
public interface RoamingStatusHistoryRepository extends JpaRepository<RoamingStatusHistory, String> {

    @Query("DELETE rsh,rs from RoamingStatusHistory rsh inner join RoamingStatus rs on rsh.msisdn = rs.msisdn where TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'",
           nativeQuery = true)
    public List<Date> deleteByDate();
}
@存储库
公共接口RoamingStatusHistoryRepository扩展了JpaRepository{
@查询(“从RoamingStatusHistory中删除rsh,rs在rsh.msisdn=rs.msisdn其中TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'上的rsh内部连接RoamingStatus rs,
nativeQuery=true)
公共列表deleteByDate();
}

我假设此查询是本机SQL查询,因此必须添加nativeQuery=true

@Repository
public interface RoamingStatusHistoryRepository extends JpaRepository<RoamingStatusHistory, String> {

    @Query("DELETE rsh,rs from RoamingStatusHistory rsh inner join RoamingStatus rs on rsh.msisdn = rs.msisdn where TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'",
           nativeQuery = true)
    public List<Date> deleteByDate();
}
@存储库
公共接口RoamingStatusHistoryRepository扩展了JpaRepository{
@查询(“从RoamingStatusHistory中删除rsh,rs在rsh.msisdn=rs.msisdn其中TIMEDIFF(NOW(),rsh.createdDate)>'00:00:30'上的rsh内部连接RoamingStatus rs,
nativeQuery=true)
公共列表deleteByDate();
}

不能从两个表中删除。或者您在数据库上使用SQL成功地做到了吗?是的,您不能从两个表中删除查询。或者,您是否在数据库上使用SQL成功地做到了这一点?是的,查询工作正常