From 253afa517a06132fb4ae419b4f77a8975ef82bfe Mon Sep 17 00:00:00 2001 From: charitha Date: Sat, 26 Oct 2019 01:42:37 +0530 Subject: [PATCH] Fix transaction handling --- .../mgt/core/service/DeviceManagementProviderServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 2669d292bb..a2f9a9769e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -3167,7 +3167,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv throws DeviceManagementException { boolean success; try { - DeviceManagementDAOFactory.openConnection(); + DeviceManagementDAOFactory.beginTransaction(); success = deviceDAO.setEnrolmentStatusInBulk(deviceType, status, getTenantId(), deviceList); DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { @@ -3175,7 +3175,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred in while updating status of devices :" + deviceType + " status : " + status; log.error(msg, e); throw new DeviceManagementException(msg, e); - } catch (SQLException e) { + } catch (TransactionManagementException e) { String msg = "Error occurred while opening a connection to the data source"; log.error(msg, e); throw new DeviceManagementException(msg, e);