fixed AttributeKvRepository

This commit is contained in:
dashevchenko 2024-01-05 14:20:00 +02:00
parent 4c77a75ef6
commit a89985efdd
2 changed files with 4 additions and 4 deletions

View File

@ -42,12 +42,12 @@ public interface AttributeKvRepository extends JpaRepository<AttributeKvEntity,
@Param("attributeType") int attributeType,
@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)
List<Integer> 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<Integer> findAllKeysByTenantId(@Param("tenantId") UUID tenantId);

View File

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