From 3c658f0afe61908f1a0cc5d74cc1e4428ba280c3 Mon Sep 17 00:00:00 2001 From: osh Date: Tue, 26 Sep 2023 17:42:37 +0530 Subject: [PATCH] Fix ownership issue in device deletion --- .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 5696c0b23fa..11992035396 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -2811,18 +2811,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * @throws DeviceManagementDAOException if refactoring fails */ public void refactorEnrolment(Connection conn, List deviceIds) throws DeviceManagementDAOException { - String updateQuery = "UPDATE DM_ENROLMENT SET OWNER = ?, OWNERSHIP = ?, STATUS = ? WHERE DEVICE_ID = ?"; + String updateQuery = "UPDATE DM_ENROLMENT SET OWNER = ?, STATUS = ? WHERE DEVICE_ID = ?"; try (PreparedStatement preparedStatement = conn.prepareStatement(updateQuery)) { for (int deviceId : deviceIds) { String randomOwner = generateRandomString(4); - String randomOwnership = generateRandomString(6); preparedStatement.setString(1, randomOwner); - preparedStatement.setString(2, randomOwnership); - preparedStatement.setString(3, String.valueOf(Status.DELETED)); - preparedStatement.setInt(4, deviceId); + preparedStatement.setString(2, String.valueOf(Status.DELETED)); + preparedStatement.setInt(3, deviceId); preparedStatement.executeUpdate(); }