From 8a8846be5af3a93752920fd9f1dec6f785876a48 Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 18 Jul 2024 12:26:19 +0530 Subject: [PATCH] Fix devices not loading in web apps --- .../mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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/AbstractEnrollmentDAOImpl.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/AbstractEnrollmentDAOImpl.java index 1160b4bb79..f826980fae 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/AbstractEnrollmentDAOImpl.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/AbstractEnrollmentDAOImpl.java @@ -731,8 +731,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { StringBuilder sql = new StringBuilder("SELECT e.DEVICE_ID, e.OWNER, e.STATUS, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ") AND d.DEVICE_TYPE_ID = ?"); + "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"); + if (deviceTypeId != 0) { + sql.append(" AND d.DEVICE_TYPE_ID = ?"); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { sql.append(" AND e.OWNER LIKE ?"); } @@ -750,7 +753,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { for (String status : allowingDeviceStatuses) { stmt.setString(index++, status); } - stmt.setInt(index++, deviceTypeId); + if (deviceTypeId != 0) { + stmt.setInt(index++, deviceTypeId); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { stmt.setString(index++, "%" + deviceOwner + "%");