Browse Source
Merge pull request #1068 from dmytro-landiak/master
jpa orderBy fix
pull/1104/head
Andrew Shvayka
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
2 deletions
-
dao/src/main/java/org/thingsboard/server/dao/sql/timeseries/JpaTimeseriesDao.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/timeseries/TsKvRepository.java
|
|
@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.data.domain.PageRequest; |
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
|
|
import org.springframework.data.domain.Sort; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.thingsboard.server.common.data.UUIDConverter; |
|
|
import org.thingsboard.server.common.data.UUIDConverter; |
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
@ -238,7 +239,9 @@ public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService imp |
|
|
query.getKey(), |
|
|
query.getKey(), |
|
|
query.getStartTs(), |
|
|
query.getStartTs(), |
|
|
query.getEndTs(), |
|
|
query.getEndTs(), |
|
|
new PageRequest(0, query.getLimit())))); |
|
|
new PageRequest(0, query.getLimit(), |
|
|
|
|
|
new Sort(Sort.Direction.fromString( |
|
|
|
|
|
query.getOrderBy()), "ts"))))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@ -35,7 +35,7 @@ public interface TsKvRepository extends CrudRepository<TsKvEntity, TsKvComposite |
|
|
|
|
|
|
|
|
@Query("SELECT tskv FROM TsKvEntity tskv WHERE tskv.entityId = :entityId " + |
|
|
@Query("SELECT tskv FROM TsKvEntity tskv WHERE tskv.entityId = :entityId " + |
|
|
"AND tskv.entityType = :entityType AND tskv.key = :entityKey " + |
|
|
"AND tskv.entityType = :entityType AND tskv.key = :entityKey " + |
|
|
"AND tskv.ts > :startTs AND tskv.ts < :endTs ORDER BY tskv.ts DESC") |
|
|
"AND tskv.ts > :startTs AND tskv.ts < :endTs") |
|
|
List<TsKvEntity> findAllWithLimit(@Param("entityId") String entityId, |
|
|
List<TsKvEntity> findAllWithLimit(@Param("entityId") String entityId, |
|
|
@Param("entityType") EntityType entityType, |
|
|
@Param("entityType") EntityType entityType, |
|
|
@Param("entityKey") String key, |
|
|
@Param("entityKey") String key, |
|
|
|