Browse Source

fixed AttributeKvRepository

pull/9850/head
dashevchenko 3 years ago
parent
commit
a89985efdd
  1. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java
  2. 4
      dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java

4
dao/src/main/java/org/thingsboard/server/dao/sql/attributes/AttributeKvRepository.java

@ -42,12 +42,12 @@ public interface AttributeKvRepository extends JpaRepository<AttributeKvEntity,
@Param("attributeType") int attributeType, @Param("attributeType") int attributeType,
@Param("attributeKey") int attributeKey); @Param("attributeKey") int attributeKey);
@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 and device_profile_id = :deviceProfileId limit 100) ORDER BY attribute_key", nativeQuery = true) "AND entity_id in (SELECT id FROM device WHERE tenant_id = :tenantId and device_profile_id = :deviceProfileId limit 100) ORDER BY attribute_key", nativeQuery = true)
List<Integer> findAllKeysByDeviceProfileId(@Param("tenantId") UUID tenantId, List<Integer> findAllKeysByDeviceProfileId(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId); @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) "AND entity_id in (SELECT id FROM device WHERE tenant_id = :tenantId limit 100) ORDER BY attribute_key", nativeQuery = true)
List<Integer> findAllKeysByTenantId(@Param("tenantId") UUID tenantId); List<Integer> findAllKeysByTenantId(@Param("tenantId") UUID tenantId);

4
dao/src/main/java/org/thingsboard/server/dao/sqlts/dictionary/JpaKeyDictionaryDao.java

@ -84,8 +84,8 @@ public class JpaKeyDictionaryDao extends JpaAbstractDaoListeningExecutorService
} }
@Override @Override
public String getKey(Integer attributeKey) { public String getKey(Integer keyId) {
Optional<KeyDictionaryEntry> byKeyId = keyDictionaryRepository.findByKeyId(attributeKey); Optional<KeyDictionaryEntry> byKeyId = keyDictionaryRepository.findByKeyId(keyId);
return byKeyId.map(KeyDictionaryEntry::getKey).orElse(null); return byKeyId.map(KeyDictionaryEntry::getKey).orElse(null);
} }

Loading…
Cancel
Save