Commit 554d9852 authored by Nguyen Ha's avatar Nguyen Ha

fix sonar

parent ebe139b6
......@@ -66,8 +66,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -76,6 +75,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
......@@ -136,7 +137,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -147,8 +148,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -157,6 +157,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder();
......@@ -214,7 +216,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -278,8 +280,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -288,6 +289,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sqlStrBuilder = new StringBuilder();
......@@ -372,7 +375,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(session != null) session.close();
}
return resultDTO;
......@@ -383,8 +386,10 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
// Session session = sessionFactory.openSession();
// session.beginTransaction();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -393,6 +398,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder sb = new StringBuilder();
......@@ -477,7 +484,9 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
if(null != session){
session.close();
}
}
return resultDTO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment