Browse Source

Entities text search by substring in JPA repositories

pull/5493/head
Viacheslav Klimov 5 years ago
committed by Andrew Shvayka
parent
commit
ab0ad885ab
  1. 42
      dao/src/main/java/org/thingsboard/server/dao/sql/alarm/AlarmRepository.java
  2. 20
      dao/src/main/java/org/thingsboard/server/dao/sql/asset/AssetRepository.java
  3. 36
      dao/src/main/java/org/thingsboard/server/dao/sql/audit/AuditLogRepository.java
  4. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java
  5. 2
      dao/src/main/java/org/thingsboard/server/dao/sql/customer/CustomerRepository.java
  6. 10
      dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java
  7. 6
      dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceProfileRepository.java
  8. 30
      dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceRepository.java
  9. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeEventRepository.java
  10. 18
      dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeRepository.java
  11. 20
      dao/src/main/java/org/thingsboard/server/dao/sql/entityview/EntityViewRepository.java
  12. 2
      dao/src/main/java/org/thingsboard/server/dao/sql/event/EventRepository.java
  13. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/ota/OtaPackageInfoRepository.java
  14. 8
      dao/src/main/java/org/thingsboard/server/dao/sql/rule/RuleChainRepository.java
  15. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantProfileRepository.java
  16. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantRepository.java
  17. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java
  18. 6
      dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java

42
dao/src/main/java/org/thingsboard/server/dao/sql/alarm/AlarmRepository.java

@ -52,9 +52,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) "
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) "
,
countQuery = "" +
"SELECT count(a) + " + //alarms with relations only
@ -70,9 +70,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
" AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
" AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
" AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
" AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) " +
" AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) " +
" )" +
"FROM AlarmEntity a " +
"INNER JOIN RelationEntity re ON a.id = re.toId " +
@ -84,9 +84,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findAlarms(@Param("tenantId") UUID tenantId,
@Param("affectedEntityId") UUID affectedEntityId,
@Param("affectedEntityType") String affectedEntityType,
@ -101,9 +101,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ",
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ",
countQuery = "" +
"SELECT count(a) " +
"FROM AlarmEntity a " +
@ -111,9 +111,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findAllAlarms(@Param("tenantId") UUID tenantId,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime,
@ -126,9 +126,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) "
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) "
,
countQuery = "" +
"SELECT count(a) " +
@ -137,9 +137,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findCustomerAlarms(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("startTime") Long startTime,

20
dao/src/main/java/org/thingsboard/server/dao/sql/asset/AssetRepository.java

@ -39,7 +39,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
AssetInfoEntity findAssetInfoById(@Param("assetId") UUID assetId);
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -48,14 +48,14 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"FROM AssetEntity a " +
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("textSearch") String textSearch,
@ -66,7 +66,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -80,7 +80,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -91,7 +91,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -100,7 +100,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -113,7 +113,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -126,7 +126,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a, RelationEntity re WHERE a.tenantId = :tenantId " +
"AND a.id = re.toId AND re.toType = 'ASSET' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -136,7 +136,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"AND a.id = re.toId AND re.toType = 'ASSET' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

36
dao/src/main/java/org/thingsboard/server/dao/sql/audit/AuditLogRepository.java

@ -34,11 +34,11 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findByTenantId(
@Param("tenantId") UUID tenantId,
@ -54,10 +54,10 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityType") EntityType entityType,
@ -74,11 +74,11 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@ -94,10 +94,10 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndUserId(@Param("tenantId") UUID tenantId,
@Param("userId") UUID userId,

4
dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java

@ -34,13 +34,13 @@ public interface ComponentDescriptorRepository extends PagingAndSortingRepositor
ComponentDescriptorEntity findByClazz(String clazz);
@Query("SELECT cd FROM ComponentDescriptorEntity cd WHERE cd.type = :type " +
"AND LOWER(cd.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(cd.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<ComponentDescriptorEntity> findByType(@Param("type") ComponentType type,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT cd FROM ComponentDescriptorEntity cd WHERE cd.type = :type " +
"AND cd.scope = :scope AND LOWER(cd.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND cd.scope = :scope AND LOWER(cd.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<ComponentDescriptorEntity> findByScopeAndType(@Param("type") ComponentType type,
@Param("scope") ComponentScope scope,
@Param("textSearch") String textSearch,

2
dao/src/main/java/org/thingsboard/server/dao/sql/customer/CustomerRepository.java

@ -30,7 +30,7 @@ import java.util.UUID;
public interface CustomerRepository extends PagingAndSortingRepository<CustomerEntity, UUID> {
@Query("SELECT c FROM CustomerEntity c WHERE c.tenantId = :tenantId " +
"AND LOWER(c.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(c.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<CustomerEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);

10
dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java

@ -32,14 +32,14 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
DashboardInfoEntity findFirstByTenantIdAndTitle(UUID tenantId, String title);
@Query("SELECT di FROM DashboardInfoEntity di WHERE di.tenantId = :tenantId " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT di FROM DashboardInfoEntity di WHERE di.tenantId = :tenantId " +
"AND di.mobileHide = false " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findMobileByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@ -47,7 +47,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
@Query("SELECT di FROM DashboardInfoEntity di, RelationEntity re WHERE di.tenantId = :tenantId " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'DASHBOARD' " +
"AND re.relationType = 'Contains' AND re.fromId = :customerId AND re.fromType = 'CUSTOMER' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -57,7 +57,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
"AND di.mobileHide = false " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'DASHBOARD' " +
"AND re.relationType = 'Contains' AND re.fromId = :customerId AND re.fromType = 'CUSTOMER' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findMobileByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -66,7 +66,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
@Query("SELECT di FROM DashboardInfoEntity di, RelationEntity re WHERE di.tenantId = :tenantId " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,

6
dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceProfileRepository.java

@ -35,21 +35,21 @@ public interface DeviceProfileRepository extends JpaRepository<DeviceProfileEnti
DeviceProfileInfo findDeviceProfileInfoById(@Param("deviceProfileId") UUID deviceProfileId);
@Query("SELECT d FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileEntity> findDeviceProfiles(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.defaultDashboardId, d.type, d.transportType) " +
"FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.defaultDashboardId, d.type, d.transportType) " +
"FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
@Param("transportType") DeviceTransportType transportType,

30
dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceRepository.java

@ -42,7 +42,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -50,7 +50,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :profileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndProfileId(@Param("tenantId") UUID tenantId,
@Param("profileId") UUID profileId,
@Param("searchText") String searchText,
@ -62,7 +62,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -73,7 +73,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
Pageable pageable);
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -83,14 +83,14 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -99,7 +99,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND d.firmwareId = null " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndTypeAndFirmwareIdIsNull(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -108,7 +108,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND d.softwareId = null " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndTypeAndSoftwareIdIsNull(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -132,7 +132,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -144,7 +144,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndDeviceProfileId(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -153,7 +153,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -167,7 +167,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -181,7 +181,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("deviceProfileId") UUID deviceProfileId,
@ -204,7 +204,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d, RelationEntity re WHERE d.tenantId = :tenantId " +
"AND d.id = re.toId AND re.toType = 'DEVICE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -214,7 +214,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"AND d.id = re.toId AND re.toType = 'DEVICE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

4
dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeEventRepository.java

@ -32,7 +32,7 @@ public interface EdgeEventRepository extends PagingAndSortingRepository<EdgeEven
"AND e.edgeId = :edgeId " +
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EdgeEventEntity> findEdgeEventsByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@ -47,7 +47,7 @@ public interface EdgeEventRepository extends PagingAndSortingRepository<EdgeEven
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND e.edgeEventAction <> 'TIMESERIES_UPDATED' " +
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EdgeEventEntity> findEdgeEventsByTenantIdAndEdgeIdWithoutTimeseriesUpdated(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,

18
dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeRepository.java

@ -31,7 +31,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("textSearch") String textSearch,
@ -44,7 +44,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
EdgeInfoEntity findEdgeInfoById(@Param("edgeId") UUID edgeId);
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -53,14 +53,14 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"FROM EdgeEntity d " +
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -71,7 +71,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -80,7 +80,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -92,7 +92,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -104,7 +104,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -114,7 +114,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT ee FROM EdgeEntity ee, RelationEntity re WHERE ee.tenantId = :tenantId " +
"AND ee.id = re.fromId AND re.fromType = 'EDGE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.toId = :entityId AND re.toType = :entityType " +
"AND LOWER(ee.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ee.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EdgeEntity> findByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityId") UUID entityId,
@Param("entityType") String entityType,

20
dao/src/main/java/org/thingsboard/server/dao/sql/entityview/EntityViewRepository.java

@ -39,7 +39,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
EntityViewInfoEntity findEntityViewInfoById(@Param("entityViewId") UUID entityViewId);
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -48,14 +48,14 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"FROM EntityViewEntity e " +
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -66,7 +66,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -74,7 +74,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -85,7 +85,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -94,7 +94,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -107,7 +107,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -124,7 +124,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT ev FROM EntityViewEntity ev, RelationEntity re WHERE ev.tenantId = :tenantId " +
"AND ev.id = re.toId AND re.toType = 'ENTITY_VIEW' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -134,7 +134,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"AND ev.id = re.toId AND re.toType = 'ENTITY_VIEW' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND ev.type = :type " +
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

2
dao/src/main/java/org/thingsboard/server/dao/sql/event/EventRepository.java

@ -55,7 +55,7 @@ public interface EventRepository extends PagingAndSortingRepository<EventEntity,
"AND e.entityType = :entityType AND e.entityId = :entityId " +
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND LOWER(e.eventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.eventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EventEntity> findEventsByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityType") EntityType entityType,

4
dao/src/main/java/org/thingsboard/server/dao/sql/ota/OtaPackageInfoRepository.java

@ -28,7 +28,7 @@ import java.util.UUID;
public interface OtaPackageInfoRepository extends CrudRepository<OtaPackageInfoEntity, UUID> {
@Query("SELECT new OtaPackageInfoEntity(f.id, f.createdTime, f.tenantId, f.deviceProfileId, f.type, f.title, f.version, f.tag, f.url, f.fileName, f.contentType, f.checksumAlgorithm, f.checksum, f.dataSize, f.additionalInfo, CASE WHEN (f.data IS NOT NULL OR f.url IS NOT NULL) THEN true ELSE false END) FROM OtaPackageEntity f WHERE " +
"f.tenantId = :tenantId " +
"AND LOWER(f.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(f.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<OtaPackageInfoEntity> findAllByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@ -38,7 +38,7 @@ public interface OtaPackageInfoRepository extends CrudRepository<OtaPackageInfoE
"AND f.deviceProfileId = :deviceProfileId " +
"AND f.type = :type " +
"AND (f.data IS NOT NULL OR f.url IS NOT NULL) " +
"AND LOWER(f.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(f.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<OtaPackageInfoEntity> findAllByTenantIdAndTypeAndDeviceProfileIdAndHasData(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("type") OtaPackageType type,

8
dao/src/main/java/org/thingsboard/server/dao/sql/rule/RuleChainRepository.java

@ -29,14 +29,14 @@ import java.util.UUID;
public interface RuleChainRepository extends PagingAndSortingRepository<RuleChainEntity, UUID> {
@Query("SELECT rc FROM RuleChainEntity rc WHERE rc.tenantId = :tenantId " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT rc FROM RuleChainEntity rc WHERE rc.tenantId = :tenantId " +
"AND rc.type = :type " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") RuleChainType type,
@Param("searchText") String searchText,
@ -45,7 +45,7 @@ public interface RuleChainRepository extends PagingAndSortingRepository<RuleChai
@Query("SELECT rc FROM RuleChainEntity rc, RelationEntity re WHERE rc.tenantId = :tenantId " +
"AND rc.id = re.toId AND re.toType = 'RULE_CHAIN' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -54,7 +54,7 @@ public interface RuleChainRepository extends PagingAndSortingRepository<RuleChai
@Query("SELECT rc FROM RuleChainEntity rc, RelationEntity re WHERE rc.tenantId = :tenantId " +
"AND rc.id = re.toId AND re.toType = 'RULE_CHAIN' AND re.relationTypeGroup = 'EDGE_AUTO_ASSIGN_RULE_CHAIN' " +
"AND re.relationType = 'Contains' AND re.fromId = :tenantId AND re.fromType = 'TENANT' " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findAutoAssignByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantProfileRepository.java

@ -33,13 +33,13 @@ public interface TenantProfileRepository extends PagingAndSortingRepository<Tena
EntityInfo findTenantProfileInfoById(@Param("tenantProfileId") UUID tenantProfileId);
@Query("SELECT t FROM TenantProfileEntity t WHERE " +
"LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantProfileEntity> findTenantProfiles(@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(t.id, 'TENANT_PROFILE', t.name) " +
"FROM TenantProfileEntity t " +
"WHERE LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"WHERE LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityInfo> findTenantProfileInfos(@Param("textSearch") String textSearch,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantRepository.java

@ -37,7 +37,7 @@ public interface TenantRepository extends PagingAndSortingRepository<TenantEntit
TenantInfoEntity findTenantInfoById(@Param("tenantId") UUID tenantId);
@Query("SELECT t FROM TenantEntity t WHERE t.region = :region " +
"AND LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantEntity> findByRegionNextPage(@Param("region") String region,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -46,7 +46,7 @@ public interface TenantRepository extends PagingAndSortingRepository<TenantEntit
"FROM TenantEntity t " +
"LEFT JOIN TenantProfileEntity p on p.id = t.tenantProfileId " +
"WHERE t.region = :region " +
"AND LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantInfoEntity> findTenantInfoByRegionNextPage(@Param("region") String region,
@Param("textSearch") String textSearch,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java

@ -34,7 +34,7 @@ public interface UserRepository extends PagingAndSortingRepository<UserEntity, U
@Query("SELECT u FROM UserEntity u WHERE u.tenantId = :tenantId " +
"AND u.customerId = :customerId AND u.authority = :authority " +
"AND LOWER(u.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(u.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<UserEntity> findUsersByAuthority(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -42,7 +42,7 @@ public interface UserRepository extends PagingAndSortingRepository<UserEntity, U
Pageable pageable);
@Query("SELECT u FROM UserEntity u WHERE u.tenantId = :tenantId " +
"AND LOWER(u.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(u.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<UserEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);

6
dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java

@ -32,19 +32,19 @@ public interface WidgetsBundleRepository extends PagingAndSortingRepository<Widg
WidgetsBundleEntity findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId = :systemTenantId " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<WidgetsBundleEntity> findSystemWidgetsBundles(@Param("systemTenantId") UUID systemTenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId = :tenantId " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<WidgetsBundleEntity> findTenantWidgetsBundlesByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId IN (:tenantId, :nullTenantId) " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<WidgetsBundleEntity> findAllTenantWidgetsBundlesByTenantId(@Param("tenantId") UUID tenantId,
@Param("nullTenantId") UUID nullTenantId,
@Param("textSearch") String textSearch,

Loading…
Cancel
Save