From d5911b900d4d50c3e79f3296cd20a382a6ffe03a Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Tue, 10 Mar 2020 12:22:38 +0530 Subject: [PATCH] Fix duplicate result issue by adding missing conditions --- .../device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 1 + .../device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 1 + .../device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 1 + .../device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 1 + 4 files changed, 4 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index e2a35770c2..7d3c6afd90 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -899,6 +899,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ") d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " + + "AND d1.DEVICE_ID = ddd.DEVICE_ID " + "AND ddi.KEY_FIELD = ? "; if (dataSourceType.contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2)) { sql += "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 2ef6697453..db30811c58 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -865,6 +865,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { ") d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " + + "AND d1.DEVICE_ID = ddd.DEVICE_ID " + "AND ddi.KEY_FIELD = ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "ORDER BY ENROLMENT_ID " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index fc137897bb..d4a6ba853e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -851,6 +851,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { ") d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " + + "AND d1.DEVICE_ID = ddd.DEVICE_ID " + "AND ddi.KEY_FIELD = ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "LIMIT ? OFFSET ?"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index ecda3ef66d..64e8912db3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -667,6 +667,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { ") d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " + + "AND d1.DEVICE_ID = ddd.DEVICE_ID " + "AND ddi.KEY_FIELD = ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "LIMIT ? OFFSET ?";