From 7688aa375d539b37639a98afe8c44a1e6e3b0fba Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Wed, 17 May 2023 05:58:02 +0000 Subject: [PATCH] Fix operation logs not loading with mssql ## Purpose * Fixes https://roadmap.entgra.net/issues/10050 ## Description * Converting BIGINT to timestamp directly is not supported with MSSQL. Timestamp class is used for conversion. Co-authored-by: prathabanKavin Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/117 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../mgt/dao/impl/operation/SQLServerOperationDAOImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java index f08d1ce510..6de5008fc8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java @@ -56,13 +56,15 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.ArrayList; -import java.util.LinkedList; + /** * This class holds the implementation of OperationDAO which can be used to support SQLServer db syntax. */ @@ -192,7 +194,7 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl { operation = new Operation(); operation.setId(rs.getInt("ID")); operation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); - operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString()); + operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString()); if (rs.getLong("UPDATED_TIMESTAMP") == 0) { operation.setReceivedTimeStamp(""); } else {