From 3d549701a4bd6bb49518cbd31e51a4261b9eec9a Mon Sep 17 00:00:00 2001 From: mharindu Date: Thu, 28 May 2015 17:45:11 +0530 Subject: [PATCH] Fixed query issue in function getDevicesByName --- .../wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index 2a38f4acaa8..61ff67e5a78 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -350,8 +350,8 @@ public class DeviceDAOImpl implements DeviceDAO { "DM_DEVICE.OWNERSHIP, DM_DEVICE.STATUS, DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_IDENTIFICATION, DM_DEVICE.OWNER, DM_DEVICE.TENANT_ID FROM " + "DM_DEVICE, DM_DEVICE_TYPE WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID " + - "AND DM_DEVICE.NAME LIKE %?% AND DM_DEVICE.TENANT_ID =?"); - stmt.setString(1, deviceName); + "AND DM_DEVICE.NAME LIKE ? AND DM_DEVICE.TENANT_ID =?"); + stmt.setString(1, deviceName + "%"); stmt.setInt(2, tenantId); ResultSet resultSet = stmt.executeQuery(); @@ -366,7 +366,6 @@ public class DeviceDAOImpl implements DeviceDAO { device.setName(resultSet.getString(5)); device.setDateOfEnrollment(resultSet.getLong(6)); device.setDateOfLastUpdate(resultSet.getLong(7)); - //TODO:- Ownership is not a enum in DeviceDAO device.setOwnerShip(resultSet.getString(8)); device.setStatus(Status.valueOf(resultSet.getString(9))); device.setDeviceTypeId(resultSet.getInt(10));