Merge pull request 'Fix DAO error in Tenant Deletion' (#380) from ashvini/device-mgt-core:FixDAOIssues into master

Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/380
This commit is contained in:
Pahansith Gunathilake 2024-04-08 19:47:19 +00:00
commit b3f91fba66
3 changed files with 4 additions and 4 deletions

View File

@ -207,7 +207,7 @@ public class TenantDAOImpl implements TenantDAO {
public void deleteDeviceOperationResponseByTenantId(int tenantId) throws DeviceManagementDAOException { public void deleteDeviceOperationResponseByTenantId(int tenantId) throws DeviceManagementDAOException {
try { try {
Connection conn = DeviceManagementDAOFactory.getConnection(); Connection conn = DeviceManagementDAOFactory.getConnection();
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ID IN " + String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE EN_OP_MAP_ID IN " +
"(SELECT ID FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ?)"; "(SELECT ID FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ?)";
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tenantId); stmt.setInt(1, tenantId);
@ -786,7 +786,7 @@ public class TenantDAOImpl implements TenantDAO {
public void deleteExternalDeviceMappingByTenantId(int tenantId) throws DeviceManagementDAOException { public void deleteExternalDeviceMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
try { try {
Connection conn = DeviceManagementDAOFactory.getConnection(); Connection conn = DeviceManagementDAOFactory.getConnection();
String sql = "DELETE FROM DM_OTP_DATA WHERE TENANT_ID = ?"; String sql = "DELETE FROM DM_EXT_DEVICE_MAPPING WHERE TENANT_ID = ?";
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, tenantId); stmt.setInt(1, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();

View File

@ -5221,8 +5221,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
tenantDao.deleteAppIconsByTenantId(tenantId); tenantDao.deleteAppIconsByTenantId(tenantId);
tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId); tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId);
tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId); tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId);
tenantDao.deleteDeviceEventByTenantId(tenantId);
tenantDao.deleteGeofenceEventMappingByTenantId(tenantId); tenantDao.deleteGeofenceEventMappingByTenantId(tenantId);
tenantDao.deleteDeviceEventByTenantId(tenantId);
tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId); tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId);
tenantDao.deleteGeofenceByTenantId(tenantId); tenantDao.deleteGeofenceByTenantId(tenantId);
tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId); tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId);

View File

@ -157,8 +157,8 @@ public class TenantManagerImpl implements TenantManager {
tenantDao.deleteAppIconsByTenantId(tenantId); tenantDao.deleteAppIconsByTenantId(tenantId);
tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId); tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId);
tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId); tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId);
tenantDao.deleteDeviceEventByTenantId(tenantId);
tenantDao.deleteGeofenceEventMappingByTenantId(tenantId); tenantDao.deleteGeofenceEventMappingByTenantId(tenantId);
tenantDao.deleteDeviceEventByTenantId(tenantId);
tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId); tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId);
tenantDao.deleteGeofenceByTenantId(tenantId); tenantDao.deleteGeofenceByTenantId(tenantId);
tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId); tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId);