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 93458c6dbc..2021d8fb94 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 @@ -97,7 +97,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -141,7 +141,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { 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/OracleDeviceDAOImpl.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/OracleDeviceDAOImpl.java index 98242e1902..1da26e841c 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/OracleDeviceDAOImpl.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/OracleDeviceDAOImpl.java @@ -98,7 +98,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -142,7 +142,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { 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 aad74dc165..7b72d1edf3 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 @@ -97,7 +97,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -136,7 +136,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isDeviceTypeProvided) { 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 2e4ec9d013..3d695e0670 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 @@ -99,7 +99,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { "WHERE DEVICE_TYPE_ID = t.ID " + "AND d.ID= i.DEVICE_ID " + "AND i.KEY_FIELD = 'serial' " + - "AND i.VALUE_FIELD = ? " + + "AND i.VALUE_FIELD LIKE ? " + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { @@ -143,7 +143,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; if (isSerialProvided) { - stmt.setString(paramIdx++, serial); + stmt.setString(paramIdx++, "%" + serial + "%"); } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) {