From 3384b597f9f3c6e4fe1911aef6cde4b38b83d8cc Mon Sep 17 00:00:00 2001 From: Shamalka Navod Date: Wed, 5 Oct 2022 18:10:49 +0000 Subject: [PATCH] Improve device name search --- .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 4 ++-- .../device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 4 ++-- .../device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 4e56e492b48..08725aeddbe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1086,7 +1086,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setInt(paramIdx++, groupId); stmt.setInt(paramIdx++, tenantId); if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); @@ -1362,7 +1362,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(paramIdx++, request.getDeviceType()); } if (isDeviceNameProvided) { - stmt.setString(paramIdx++, request.getDeviceName() + "%"); + stmt.setString(paramIdx++, "%" + request.getDeviceName() + "%"); } stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { 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 1f42fc698f2..38fc88825d6 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 @@ -152,7 +152,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, deviceType); } if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { @@ -521,7 +521,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setInt(paramIdx++, groupId); stmt.setInt(paramIdx++, tenantId); if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); 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 49b4f88c2a3..08c5afd3118 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 @@ -152,7 +152,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, deviceType); } if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { @@ -501,7 +501,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setInt(paramIdx++, groupId); stmt.setInt(paramIdx++, tenantId); if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); 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 133464a633f..7fdaaca4bd9 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 @@ -143,7 +143,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, deviceType); } if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { @@ -480,7 +480,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setInt(paramIdx++, groupId); stmt.setInt(paramIdx++, tenantId); if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); 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 7686ada7ea7..baf3f92f618 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 @@ -153,7 +153,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, deviceType); } if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { @@ -500,7 +500,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setInt(paramIdx++, groupId); stmt.setInt(paramIdx++, tenantId); if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); + stmt.setString(paramIdx++, "%" + deviceName + "%"); } if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime()));