Avoid unnecessary db connection

reporting
Charitha Goonetilleke 5 years ago
parent f59242d6b8
commit 9280810b24

@ -289,12 +289,11 @@ public class MonitoringManagerImpl implements MonitoringManager {
PolicyManagementDAOFactory.closeConnection(); PolicyManagementDAOFactory.closeConnection();
} }
if (!firstTimeComplianceData.isEmpty()) {
try { try {
PolicyManagementDAOFactory.beginTransaction(); PolicyManagementDAOFactory.beginTransaction();
if (!firstTimeComplianceData.isEmpty()) {
monitoringDAO.addComplianceDetails(firstTimeComplianceData); monitoringDAO.addComplianceDetails(firstTimeComplianceData);
PolicyManagementDAOFactory.commitTransaction(); PolicyManagementDAOFactory.commitTransaction();
}
} catch (MonitoringDAOException e) { } catch (MonitoringDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction(); PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Error occurred from monitoring dao.", e); throw new PolicyComplianceException("Error occurred from monitoring dao.", e);
@ -304,6 +303,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
} finally { } finally {
PolicyManagementDAOFactory.closeConnection(); PolicyManagementDAOFactory.closeConnection();
} }
}
if (!notifiableDeviceEnrollments.isEmpty()) { if (!notifiableDeviceEnrollments.isEmpty()) {
try { try {

Loading…
Cancel
Save