From 6b72f7110198a2b4de6f8e430078d14be62437ca Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Wed, 16 Oct 2019 11:34:34 +0530 Subject: [PATCH] Fic MsSQL and Oracle prepared statement building issue --- .../impl/application/OracleApplicationDAOImpl.java | 2 +- .../application/SQLServerApplicationDAOImpl.java | 2 +- .../core/dao/impl/review/OracleReviewDAOImpl.java | 12 ++++++------ .../core/dao/impl/review/SQLServerReviewDAOImpl.java | 12 ++++++------ .../impl/subscription/OracleSubscriptionDAOImpl.java | 12 ++++++------ .../subscription/SQLServerSubscriptionDAOImpl.java | 12 ++++++------ 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java index f78caaf7d35..1ed3ae0ec5f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java @@ -135,12 +135,12 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql); ){ if (filter.getLimit() != -1) { + stmt.setInt(paramIndex++, filter.getOffset()); if (filter.getLimit() == 0) { stmt.setInt(paramIndex++, 100); } else { stmt.setInt(paramIndex++, filter.getLimit()); } - stmt.setInt(paramIndex++, filter.getOffset()); } stmt.setInt(paramIndex++, tenantId); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java index 8cfe1ea71f0..6ed7ca72cea 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java @@ -133,12 +133,12 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql); ){ if (filter.getLimit() != -1) { + stmt.setInt(paramIndex++, filter.getOffset()); if (filter.getLimit() == 0) { stmt.setInt(paramIndex++, 100); } else { stmt.setInt(paramIndex++, filter.getLimit()); } - stmt.setInt(paramIndex++, filter.getOffset()); } stmt.setInt(paramIndex++, tenantId); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java index b05391d306d..f24aac96ca4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java @@ -70,8 +70,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { statement.setInt(1, releaseId); statement.setInt(2, Constants.REVIEW_PARENT_ID); statement.setInt(3, tenantId); - statement.setInt(4, request.getLimit()); - statement.setInt(5, request.getOffSet()); + statement.setInt(4, request.getOffSet()); + statement.setInt(5, request.getLimit()); try (ResultSet rs = statement.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -124,8 +124,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { } ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -180,8 +180,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setString(index++, username); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java index 91182b9e284..ccad696597b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java @@ -70,8 +70,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { statement.setInt(1, releaseId); statement.setInt(2, Constants.REVIEW_PARENT_ID); statement.setInt(3, tenantId); - statement.setInt(4, request.getLimit()); - statement.setInt(5, request.getOffSet()); + statement.setInt(4, request.getOffSet()); + statement.setInt(5, request.getLimit()); try (ResultSet rs = statement.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -124,8 +124,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { } ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -180,8 +180,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setString(index++, username); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java index ffda6ed4c8d..439fdbf1177 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java @@ -55,8 +55,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, appReleaseId); stmt.setInt(2, tenantId); - stmt.setInt(3, limitValue); - stmt.setInt(4, offsetValue); + stmt.setInt(3, offsetValue); + stmt.setInt(4, limitValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER")); @@ -95,8 +95,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -135,8 +135,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS")); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java index eefa4832eab..b3a93749e64 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java @@ -55,8 +55,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, appReleaseId); stmt.setInt(2, tenantId); - stmt.setInt(3, limitValue); - stmt.setInt(4, offsetValue); + stmt.setInt(3, offsetValue); + stmt.setInt(4, limitValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER")); @@ -95,8 +95,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -135,8 +135,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS"));