Browse Source
Merge pull request #9443 from thingsboard/fix/delete-queries
Fix delete queries
pull/9474/head
Andrew Shvayka
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
30 additions and
9 deletions
-
dao/src/main/java/org/thingsboard/server/dao/sql/alarm/EntityAlarmRepository.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationRepository.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationRequestRepository.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationRuleRepository.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationTargetRepository.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationTemplateRepository.java
|
|
|
@ -36,6 +36,8 @@ public interface EntityAlarmRepository extends JpaRepository<EntityAlarmEntity, |
|
|
|
void deleteByEntityId(@Param("entityId") UUID entityId); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByTenantId(UUID tenantId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM EntityAlarmEntity a WHERE a.tenantId = :tenantId") |
|
|
|
void deleteByTenantId(@Param("tenantId") UUID tenantId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -59,13 +59,19 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity |
|
|
|
Page<NotificationEntity> findByRequestId(UUID requestId, Pageable pageable); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
int deleteByIdAndRecipientId(UUID id, UUID recipientId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationEntity n WHERE n.id = :id AND n.recipientId = :recipientId") |
|
|
|
int deleteByIdAndRecipientId(@Param("id") UUID id, @Param("recipientId") UUID recipientId); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByRequestId(UUID requestId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationEntity n WHERE n.requestId = :requestId") |
|
|
|
void deleteByRequestId(@Param("requestId") UUID requestId); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByRecipientId(UUID recipientId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationEntity n WHERE n.recipientId = :recipientId") |
|
|
|
void deleteByRecipientId(@Param("recipientId") UUID recipientId); |
|
|
|
|
|
|
|
@Modifying |
|
|
|
@Transactional |
|
|
|
|
|
|
|
@ -70,9 +70,13 @@ public interface NotificationRequestRepository extends JpaRepository<Notificatio |
|
|
|
boolean existsByTenantIdAndStatusAndTemplateId(UUID tenantId, NotificationRequestStatus status, UUID templateId); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
int deleteAllByCreatedTimeBefore(long ts); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationRequestEntity r WHERE r.createdTime < :ts") |
|
|
|
int deleteAllByCreatedTimeBefore(@Param("ts") long ts); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByTenantId(UUID tenantId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationRequestEntity r WHERE r.tenantId = :tenantId") |
|
|
|
void deleteByTenantId(@Param("tenantId") UUID tenantId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ package org.thingsboard.server.dao.sql.notification; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
import org.springframework.data.jpa.repository.Modifying; |
|
|
|
import org.springframework.data.jpa.repository.Query; |
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
@ -58,7 +59,9 @@ public interface NotificationRuleRepository extends JpaRepository<NotificationRu |
|
|
|
Pageable pageable); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByTenantId(UUID tenantId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationRuleEntity r WHERE r.tenantId = :tenantId") |
|
|
|
void deleteByTenantId(@Param("tenantId") UUID tenantId); |
|
|
|
|
|
|
|
NotificationRuleEntity findByTenantIdAndName(UUID tenantId, String name); |
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ package org.thingsboard.server.dao.sql.notification; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
import org.springframework.data.jpa.repository.Modifying; |
|
|
|
import org.springframework.data.jpa.repository.Query; |
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
@ -49,7 +50,9 @@ public interface NotificationTargetRepository extends JpaRepository<Notification |
|
|
|
List<NotificationTargetEntity> findByTenantIdAndIdIn(UUID tenantId, List<UUID> ids); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByTenantId(UUID tenantId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationTargetEntity t WHERE t.tenantId = :tenantId") |
|
|
|
void deleteByTenantId(@Param("tenantId") UUID tenantId); |
|
|
|
|
|
|
|
long countByTenantId(UUID tenantId); |
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ package org.thingsboard.server.dao.sql.notification; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.Pageable; |
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
import org.springframework.data.jpa.repository.Modifying; |
|
|
|
import org.springframework.data.jpa.repository.Query; |
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
@ -42,7 +43,9 @@ public interface NotificationTemplateRepository extends JpaRepository<Notificati |
|
|
|
Pageable pageable); |
|
|
|
|
|
|
|
@Transactional |
|
|
|
void deleteByTenantId(UUID tenantId); |
|
|
|
@Modifying |
|
|
|
@Query("DELETE FROM NotificationTemplateEntity t WHERE t.tenantId = :tenantId") |
|
|
|
void deleteByTenantId(@Param("tenantId") UUID tenantId); |
|
|
|
|
|
|
|
NotificationTemplateEntity findByTenantIdAndName(UUID tenantId, String name); |
|
|
|
|
|
|
|
|