From 5532db6dd45fd7be9390d25443f460acc7cc0a55 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 26 May 2016 17:10:37 +0530 Subject: [PATCH] Fixed https://wso2.org/jira/browse/IOTS-177 --- .../device/mgt/core/dao/impl/DeviceTypeDAOImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java index bccddcee408..8ef838ef8ea 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java @@ -68,9 +68,10 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { conn = this.getConnection(); String sql = "SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE where PROVIDER_TENANT_ID =" + - "? OR SHARED_WITH_ALL_TENANTS = TRUE"; + "? OR SHARED_WITH_ALL_TENANTS = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); + stmt.setBoolean(2, true); rs = stmt.executeQuery(); while (rs.next()) { @@ -125,8 +126,9 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { conn = this.getConnection(); String sql = "SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE where " + - "SHARED_WITH_ALL_TENANTS = TRUE"; + "SHARED_WITH_ALL_TENANTS = ?"; stmt = conn.prepareStatement(sql); + stmt.setBoolean(1, true); rs = stmt.executeQuery(); while (rs.next()) { @@ -179,10 +181,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO { try { conn = this.getConnection(); String sql = "SELECT ID AS DEVICE_TYPE_ID FROM DM_DEVICE_TYPE WHERE (PROVIDER_TENANT_ID =? OR " + - "SHARED_WITH_ALL_TENANTS = TRUE) AND NAME =?"; + "SHARED_WITH_ALL_TENANTS = ?) AND NAME =?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); - stmt.setString(2, type); + stmt.setBoolean(2, true); + stmt.setString(3, type); rs = stmt.executeQuery(); if (rs.next()) { deviceType = new DeviceType();