diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 11ea9592259..1753f9696ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -616,7 +616,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (device == null) { throw new DeviceNotFoundException("Device not found for id '" + deviceIdentifier.getId() + "'"); } - this.groupDAO.addDevice(groupId, device.getId(), tenantId); + if (!this.groupDAO.isDeviceMappedToGroup(groupId, device.getId(), tenantId)){ + this.groupDAO.addDevice(groupId, device.getId(), tenantId); + } } GroupManagementDAOFactory.commitTransaction(); } catch (DeviceManagementException e) {