From fb3797774e8f4413bf306bcd7c65afb79c0708a6 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 23 Feb 2023 00:36:14 +0530 Subject: [PATCH] Add fix to load apps and create app --- .../dao/impl/application/SQLServerApplicationDAOImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java index 9ad0b9d4c0..bfce4e31fa 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java @@ -94,6 +94,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { || StringUtils.isNotEmpty(filter.getAppReleaseType())) { sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "; } + sql += "WHERE AP_APP.TENANT_ID = ? "; if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { sql += "AND AP_APP.TYPE = ? "; } @@ -128,7 +129,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { sql += filter.getSortBy() +" "; } if (filter.getLimit() != -1) { - sql += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY "; + sql += "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY "; } sql += ") AS app_data ON app_data.ID = AP_APP.ID " + "LEFT JOIN (" @@ -145,6 +146,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndex = 1; + stmt.setInt(paramIndex++, tenantId); if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { stmt.setString(paramIndex++, filter.getAppType()); }