Fix duplicate result issue by adding missing conditions

merge-requests/458/head
Yohan Avishke 5 years ago
parent f38c1d4ab3
commit d5911b900d

@ -899,6 +899,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
") d1 " + ") d1 " +
"WHERE d1.DEVICE_ID = e.DEVICE_ID " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " +
"AND d1.DEVICE_ID = ddi.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " +
"AND d1.DEVICE_ID = ddd.DEVICE_ID " +
"AND ddi.KEY_FIELD = ? "; "AND ddi.KEY_FIELD = ? ";
if (dataSourceType.contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2)) { if (dataSourceType.contains(DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2)) {
sql += "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? "; sql += "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? ";

@ -865,6 +865,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
") d1 " + ") d1 " +
"WHERE d1.DEVICE_ID = e.DEVICE_ID " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " +
"AND d1.DEVICE_ID = ddi.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " +
"AND d1.DEVICE_ID = ddd.DEVICE_ID " +
"AND ddi.KEY_FIELD = ? " + "AND ddi.KEY_FIELD = ? " +
"AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " +
"ORDER BY ENROLMENT_ID " + "ORDER BY ENROLMENT_ID " +

@ -851,6 +851,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
") d1 " + ") d1 " +
"WHERE d1.DEVICE_ID = e.DEVICE_ID " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " +
"AND d1.DEVICE_ID = ddi.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " +
"AND d1.DEVICE_ID = ddd.DEVICE_ID " +
"AND ddi.KEY_FIELD = ? " + "AND ddi.KEY_FIELD = ? " +
"AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " +
"LIMIT ? OFFSET ?"; "LIMIT ? OFFSET ?";

@ -667,6 +667,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
") d1 " + ") d1 " +
"WHERE d1.DEVICE_ID = e.DEVICE_ID " + "WHERE d1.DEVICE_ID = e.DEVICE_ID " +
"AND d1.DEVICE_ID = ddi.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " +
"AND d1.DEVICE_ID = ddd.DEVICE_ID " +
"AND ddi.KEY_FIELD = ? " + "AND ddi.KEY_FIELD = ? " +
"AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " +
"LIMIT ? OFFSET ?"; "LIMIT ? OFFSET ?";

Loading…
Cancel
Save