From a89985efdd4bad3ed6b81cf8113f74dda5974a90 Mon Sep 17 00:00:00 2001 From: dashevchenko Date: Fri, 5 Jan 2024 14:20:00 +0200 Subject: [PATCH] fixed AttributeKvRepository --- .../server/dao/sql/attributes/AttributeKvRepository.java | 4 ++-- .../server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java index a43be3e49d..f5487971c9 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java @@ -42,12 +42,12 @@ public interface AttributeKvRepository extends JpaRepository findAllKeysByDeviceProfileId(@Param("tenantId") UUID tenantId, @Param("deviceProfileId") UUID deviceProfileId); - @Query(value = "SELECT DISTINCT attribute_key FROM attribute_kv WHERE entity_type = 'DEVICE' " + + @Query(value = "SELECT DISTINCT attribute_key FROM attribute_kv WHERE " + "AND entity_id in (SELECT id FROM device WHERE tenant_id = :tenantId limit 100) ORDER BY attribute_key", nativeQuery = true) List findAllKeysByTenantId(@Param("tenantId") UUID tenantId); diff --git a/dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java b/dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java index 3c2a4cd228..90bb3bbed0 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java @@ -84,8 +84,8 @@ public class JpaKeyDictionaryDao extends JpaAbstractDaoListeningExecutorService } @Override - public String getKey(Integer attributeKey) { - Optional byKeyId = keyDictionaryRepository.findByKeyId(attributeKey); + public String getKey(Integer keyId) { + Optional byKeyId = keyDictionaryRepository.findByKeyId(keyId); return byKeyId.map(KeyDictionaryEntry::getKey).orElse(null); }