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/device/GenericDeviceDAOImpl.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/device/GenericDeviceDAOImpl.java index e116df7490..5586be8002 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/device/GenericDeviceDAOImpl.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/device/GenericDeviceDAOImpl.java @@ -1317,7 +1317,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { query += " AND i.VALUE_FIELD LIKE ?" ; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -1347,7 +1347,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); @@ -1356,7 +1356,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setString(index++, "%" + serial + "%"); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) { 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/device/PostgreSQLDeviceDAOImpl.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/device/PostgreSQLDeviceDAOImpl.java index 0f502cf874..ac63399d38 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/device/PostgreSQLDeviceDAOImpl.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/device/PostgreSQLDeviceDAOImpl.java @@ -1068,7 +1068,7 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { isOwnershipProvided = true; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -1099,13 +1099,13 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) { 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/device/SQLServerDeviceDAOImpl.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/device/SQLServerDeviceDAOImpl.java index 7de242ead9..9dc29afa72 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/device/SQLServerDeviceDAOImpl.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/device/SQLServerDeviceDAOImpl.java @@ -936,7 +936,7 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { isOwnershipProvided = true; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -967,13 +967,13 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) {