From f0c48c585de2311dd71cae55e46164b77645158d Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Fri, 7 Jun 2024 13:04:51 +0530 Subject: [PATCH] Fix sql syntax errors --- .../mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 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/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index e95183d8c3..58bfed7d4a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1036,12 +1036,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "(SELECT gd.DEVICE_ID, " + "gd.DESCRIPTION, " + "gd.NAME, " + - "gd.DEVICE_IDENTIFICATION, " + + "gd.DEVICE_IDENTIFICATION " + "FROM " + "(SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + @@ -2365,7 +2365,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "e.device_id," + "e.status, " + "e.date_of_last_update, " + - "e.date_of_enrolment " + + "e.date_of_enrolment, " + "e.DEVICE_TYPE " + "FROM dm_enrolment e " + "INNER JOIN " + @@ -2375,7 +2375,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "KEY_FIELD = 'encryptionEnabled' " + "AND VALUE_FIELD = ?) AS di " + "ON di.DEVICE_ID = e.DEVICE_ID " + - "WHERE e.tenant_id = ?) e1, " + + "WHERE e.tenant_id = ?) e1 " + "WHERE d.id = e1.device_id " + "ORDER BY e1.date_of_last_update DESC " + "LIMIT ? OFFSET ?"; @@ -2409,7 +2409,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { Connection conn = getConnection(); String sql = - "SELECT COUNT(DEVICE_ID) " + + "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT " + "FROM DM_DEVICE_INFO " + "WHERE KEY_FIELD = 'encryptionEnabled' " + "AND VALUE_FIELD = ?"; @@ -2417,7 +2417,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setBoolean(1, isEncrypted); - ps.setInt(2, tenantId); try (ResultSet rs = ps.executeQuery()) { return rs.next() ? rs.getInt("DEVICE_COUNT") : 0;