From 0621579d2581303e2b459291b8517b2b94cf4dfa Mon Sep 17 00:00:00 2001 From: Thomson Ignesious Date: Mon, 5 Jun 2017 18:25:15 +0530 Subject: [PATCH 1/2] case sensitiv stmt = conn.prepareStatement(sql, new String[]{"ID"}) this line makes case sensitive issues, an exception saying 'ID' does not exist while using the postgreSQL. --- .../org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java index 7d9947a421..ddc120a5c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java @@ -47,7 +47,7 @@ public class GroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID) VALUES (?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[]{"ID"}); + stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt.setString(1, deviceGroup.getDescription()); stmt.setString(2, deviceGroup.getName()); stmt.setString(3, deviceGroup.getOwner()); From f2fbf97b91847de90ce73dfc884a1a3cf20a012f Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 22 Nov 2017 15:41:23 +0530 Subject: [PATCH 2/2] Reverting to column name based return of the generated keys as Statement.RETURN_GENERATED_KEYS are not handled consistently by H2 engine --- .../carbon/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 19f88a2428..44b1384c09 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -45,7 +45,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID) VALUES (?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + stmt = conn.prepareStatement(sql, new String[]{"ID"}); stmt.setString(1, deviceGroup.getDescription()); stmt.setString(2, deviceGroup.getName()); stmt.setString(3, deviceGroup.getOwner());