From 96e3c3f0e03a0a12b2750929f7430ed75d471694 Mon Sep 17 00:00:00 2001 From: osh Date: Thu, 1 Jun 2023 23:37:01 +0530 Subject: [PATCH] Fix search by user fixes https://roadmap.entgra.net/issues/10113 --- .../core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 4 ++-- .../device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/AbstractDeviceDAOImpl.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/AbstractDeviceDAOImpl.java index 72af9f3d1c..6b06c28d60 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/AbstractDeviceDAOImpl.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/AbstractDeviceDAOImpl.java @@ -1323,7 +1323,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -1351,7 +1351,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(paramIdx++, request.getOwnership()); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); } 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 8869be2f50..b3c6b8f18a 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 @@ -126,7 +126,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -158,7 +158,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, ownership); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); }