From 1a12838b7cf893283fc2b5ebbda65faf9efec175 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 26 Sep 2016 17:16:27 +0530 Subject: [PATCH] Fixed issue in NotificationDAO due to invalid column name --- .../mgt/dao/impl/AbstractNotificationDAOImpl.java | 8 ++++---- .../notification/mgt/dao/util/NotificationDAOUtil.java | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java index abe94ea4b9..bf80177509 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java @@ -75,8 +75,8 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO { try { conn = NotificationManagementDAOFactory.getConnection(); String sql = - "SELECT NOTIFICATION_ID, OPERATION_ID, DESCRIPTION, STATUS, DEVICE_IDENTIFICATION, DEVICE_NAME, " + - "DEVICE TYPE FROM DM_NOTIFICATION WHERE TENANT_ID = ? AND NOTIFICATION_ID = ?"; + "SELECT NOTIFICATION_ID, OPERATION_ID, DESCRIPTION, STATUS FROM DM_NOTIFICATION WHERE " + + "TENANT_ID = ? AND NOTIFICATION_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setInt(2, notificationId); @@ -161,7 +161,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO { rs = stmt.executeQuery(); notifications = new ArrayList<>(); while (rs.next()) { - notifications.add(NotificationDAOUtil.getNotification(rs)); + notifications.add(NotificationDAOUtil.getNotificationWithDeviceInfo(rs)); } } catch (SQLException e) { throw new NotificationManagementException( @@ -234,7 +234,7 @@ public abstract class AbstractNotificationDAOImpl implements NotificationDAO { rs = stmt.executeQuery(); notifications = new ArrayList<>(); while (rs.next()) { - notifications.add(NotificationDAOUtil.getNotification(rs)); + notifications.add(NotificationDAOUtil.getNotificationWithDeviceInfo(rs)); } } catch (SQLException e) { throw new NotificationManagementException( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java index abfddf13ee..68519f0742 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java @@ -126,6 +126,15 @@ public class NotificationDAOUtil { } public static Notification getNotification(ResultSet rs) throws SQLException { + Notification notification = new Notification(); + notification.setNotificationId(rs.getInt("NOTIFICATION_ID")); + notification.setOperationId(rs.getInt("OPERATION_ID")); + notification.setDescription(rs.getString("DESCRIPTION")); + notification.setStatus(rs.getString("STATUS")); + return notification; + } + + public static Notification getNotificationWithDeviceInfo(ResultSet rs) throws SQLException { Notification notification = new Notification(); notification.setNotificationId(rs.getInt("NOTIFICATION_ID")); notification.setOperationId(rs.getInt("OPERATION_ID"));