diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java index b51f6a53e0..2bb99fe75b 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -315,6 +315,9 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { String countQuery = String.format("select count(id) %s", fromClauseCount); int totalElements = jdbcTemplate.queryForObject(countQuery, ctx, Integer.class); + if (totalElements == 0) { + return new PageData<>(); + } String dataQuery = String.format("select * %s", fromClauseData); EntityDataSortOrder sortOrder = pageLink.getSortOrder();