From 9d268e19fb3d41707b446f6ebca154e662eed17b Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 16 Aug 2023 09:19:33 +0530 Subject: [PATCH] Fix enrolment app install issue --- .../mgt/core/dao/impl/ApplicationDAOImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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/ApplicationDAOImpl.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/ApplicationDAOImpl.java index 4f46d5b4f6..2d5dde27dc 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/ApplicationDAOImpl.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/ApplicationDAOImpl.java @@ -299,7 +299,13 @@ public class ApplicationDAOImpl implements ApplicationDAO { if (filter != null) { sql = sql + "AND NAME LIKE ? "; } - sql = sql + "LIMIT ? OFFSET ?"; + + boolean isLimitPresent = false; + if (request.getRowCount() > 0) { + sql = sql + "LIMIT ? OFFSET ?"; + isLimitPresent = true; + } + Connection conn = this.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -308,8 +314,10 @@ public class ApplicationDAOImpl implements ApplicationDAO { if (filter != null){ stmt.setString(paramIdx++, filter); } - stmt.setInt(paramIdx++, request.getRowCount()); - stmt.setInt(paramIdx, request.getStartIndex()); + if (isLimitPresent) { + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) {