From 641ddbfb85c8f3b8cdcfeba30d423502c087b80f Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 6 Jun 2024 09:50:27 +0530 Subject: [PATCH] Fix sql syntax errors --- .../jaxrs/service/impl/GroupManagementServiceImpl.java | 2 +- .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 7 +++---- .../device/mgt/core/dao/impl/AbstractGroupDAOImpl.java | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index fc8f080b07..e8c56680b1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -273,7 +273,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { ); return Response.status(Response.Status.OK).build(); } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while updating group. "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupNotExistException e) { 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 7ab1cdb6e3..e95183d8c3 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 @@ -176,7 +176,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.DESCRIPTION, " + "d.NAME, " + "d.LAST_UPDATED_TIMESTAMP " - + "FROM DM_DEVICE d" + + "FROM DM_DEVICE d WHERE " + "d.DEVICE_IDENTIFICATION = ? AND " + "d.TENANT_ID = ?"; @@ -197,7 +197,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndx = 1; - stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getType()); stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getId()); stmt.setInt(paramIndx++, tenantId); if (deviceData.getLastModifiedDate() != null) { @@ -964,12 +963,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.NAME AS DEVICE_NAME, " + "d.DEVICE_IDENTIFICATION, " + "d.LAST_UPDATED_TIMESTAMP, " - + "e.DEVICE_TYPE " + + "e1.DEVICE_TYPE " + "FROM " + "DM_DEVICE d, " + "(SELECT " + "e.OWNER, " - + "e.DEVICE_TYPE " + + "e.DEVICE_TYPE, " + "e.OWNERSHIP, " + "e.ID AS ENROLMENT_ID, " + "e.DEVICE_ID, " 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/AbstractGroupDAOImpl.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/AbstractGroupDAOImpl.java index 374c1ca0aa..c65692870d 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/AbstractGroupDAOImpl.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/AbstractGroupDAOImpl.java @@ -1282,8 +1282,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { StringJoiner joiner = new StringJoiner(",","SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "e.DEVICE_NAME, " - + "d1.DEVICE_TYPE, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " @@ -1343,8 +1343,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { String sql = "SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "e.DEVICE_NAME, " - + "d1.DEVICE_TYPE, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, "