List of usage examples for org.hibernate Query setResultTransformer
@Deprecated Query<R> setResultTransformer(ResultTransformer transformer);
From source file:com.nec.harvest.service.impl.ActualViewServiceImpl.java
License:Open Source License
/** {@inheritDoc}*/ @Override// ww w . jav a2 s . c o m public List<VJiseki> findByOrgCodeAndPeriodMonthly(String orgCode, String startMonth, String endMonth) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException("Organization must not be null or empty"); } if (StringUtils.isEmpty(startMonth)) { throw new IllegalArgumentException("Start month must not be null or empty"); } if (StringUtils.isEmpty(endMonth)) { throw new IllegalArgumentException("End month must not be null or empty"); } // logger.info(" Find soneki suii by organization's code " + orgCode + " startMonth " + startMonth + " endMonth " + endMonth); final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<VJiseki> jisekis = new ArrayList<>(); try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder( " SELECT c.pk.organization.strCode as strCode, c.pk.getSudo as getSudo, c.uriSkKG as uriSkKG, c.KtSkKG as ktSkKG, c.IdoSkKGU as idoSkKGU, c.IdoSkKGH as idoSkKGH, c.uriKrKG as uriKrKG, c.ktKrKG as ktKrKG, c.knSrKG as knSrKG, "); sql.append( " c.ktSrKG as ktSrKG, c.kgcSrKG as kgcSrKG, c.idoSrKGU as idoSrKGU, c.idoSrKGH as idoSrKGH, c.ktJkKG as ktJkKG, c.jkJkKG as jkJkKG, c.kgcJkKG as kgcJkKG, c.idoJkKGU as idoJkKGU, c.idoJkKGH as idoJkKGH, c.helpJkKGU as helpJkKGU, c.helpJkKGH as helpJkKGH, c.ktKhKG as ktKhKG, "); sql.append( " c.knKhKG as knKhKG, c.kgcKhKG as kgcKhKG, c.idoKhKGU as idoKhKGU, c.idoKhKGH as idoKhKGH, c.uriKhKG as uriKhKG "); sql.append(" FROM VJiseki c "); sql.append(" WHERE c.pk.organization.strCode = :strCode "); sql.append(" AND c.pk.getSudo >= :startMonth "); sql.append(" AND c.pk.getSudo <= :endMonth ORDER BY c.pk.getSudo"); // Query query = repository.getQuery(session, sql.toString()); query.setParameter("strCode", orgCode); query.setParameter("startMonth", startMonth); query.setParameter("endMonth", endMonth); query.setResultTransformer(Transformers.aliasToBean(VJiseki.class)); // jisekis = repository.findByQuery(query); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(jisekis)) { throw new ObjectNotFoundException("There is no actual view object"); } } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while getting the data for organization " + orgCode, ex); } finally { HibernateSessionManager.closeSession(session); } return jisekis; }
From source file:com.nec.harvest.service.impl.ActualViewServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w. j a v a 2s. co m*/ public List<VJiseki> findByOrgCodesAndMonth(String month, String... orgCodes) throws ServiceException { if (StringUtils.isEmpty(month)) { throw new IllegalArgumentException("Can not find actual view objects with month empty"); } if (ArrayUtils.isEmpty(orgCodes)) { throw new IllegalArgumentException("Can not find actual view objects with organization codes null"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<VJiseki> jisekis = new ArrayList<>(); try { tx = session.beginTransaction(); Query query = repository.getSQLQuery(session, " SELECT StrCode as strCode, UriSkKG as uriSkKG, KtSkKG as ktSkKG, IdoSkKGU as idoSkKGU, IdoSkKGH as idoSkKGH, UriKrKG as uriKrKG, " + " KtKrKG as ktKrKG, KnSrKG as knSrKG, KtSrKG as ktSrKG, " + " KgcSrKG as kgcSrKG, IdoSrKGU as idoSrKGU, IdoSrKGH as idoSrKGH, " + " KtJkKG as ktJkKG, JkJkKG as jkJkKG, KgcJkKG as kgcJkKG, " + " IdoJkKGU as idoJkKGU, IdoJkKGH as idoJkKGH, HelpJkKGU as helpJkKGU, HelpJkKGH as helpJkKGH, " + " KtKhKG as ktKhKG, KnKhKG as knKhKG, KgcKhKG as kgcKhKG, " + " IdoKhKGU as idoKhKGU, IdoKhKGH as idoKhKGH, UriKhKG as uriKhKG " + " FROM V_JISEKI WHERE StrCode IN (:orgCodes) AND Getsudo = :month"); query.setParameterList("orgCodes", orgCodes); query.setString("month", month); query.setResultTransformer(Transformers.aliasToBean(VJiseki.class)); // jisekis = repository.findByQuery(query); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(jisekis)) { throw new ObjectNotFoundException("No jisekis (actual view object) found"); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "An exception occur when get a list of actual view objects of multi organization and month", ex); } finally { HibernateSessionManager.closeSession(session); } return jisekis; }
From source file:com.nec.harvest.service.impl.ActualViewServiceImpl.java
License:Open Source License
/** {@inheritDoc}*/ @Override// w w w. j a va 2 s . c o m public List<VJiseki> findByPeriodMonthlyAndOrgCodes(String startMonth, String endMonth, List<String> orgCodes) throws ServiceException { if (CollectionUtils.isEmpty(orgCodes)) { throw new IllegalArgumentException("Organizations must not be null or empty"); } if (StringUtils.isEmpty(startMonth)) { throw new IllegalArgumentException("Start month must not be null or empty"); } if (StringUtils.isEmpty(endMonth)) { throw new IllegalArgumentException("End month must not be null or empty"); } // logger.info(" Find soneki suii by organization's code " + StringUtils.join(orgCodes, ",") + " startMonth " + startMonth + " endMonth " + endMonth); final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<VJiseki> jisekis = new ArrayList<>(); try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder( " SELECT c.getSudo as getSudo, c.uriSkKG, c.ktSkKG, c.idoSkKGU, c.idoSkKGH, c.uriKrKG, "); sql.append( " c.ktKrKG, c.knSrKG, c.ktSrKG, c.kgcSrKG, c.idoSrKGU, c.idoSrKGH, c.jkJkKG, c.kgcJkKG, c.idoJkKGU, c.idoJkKGH, "); sql.append( " c.helpJkKGU, c.helpJkKGH, c.ktKhKG, c.knKhKG, c.kgcKhKG, c.idoKhKGU, c.idoKhKGH, c.uriKhKG, c.ktJkKG"); sql.append(" FROM v_jiseki c WHERE c.strCode IN (:strCode) "); sql.append(" AND c.getSudo >= :startMonth AND c.getSudo <= :endMonth "); sql.append(" ORDER BY c.getSudo "); // get data in v_jiseki view Query query = repository.getSQLQuery(session, sql.toString()); query.setParameterList("strCode", orgCodes); query.setParameter("startMonth", startMonth); query.setParameter("endMonth", endMonth); query.setResultTransformer(Transformers.aliasToBean(VJiseki.class)); jisekis = repository.findByQuery(query); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(jisekis)) { throw new ObjectNotFoundException("There is no actual view object"); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while getting the data for organization " + StringUtils.join(orgCodes, ","), ex); } finally { HibernateSessionManager.closeSession(session); } return jisekis; }
From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w . ja v a 2s. com*/ public Map<String, BudgetPerformanceBean> findByOrgCodesAndMonthAndKmkCodeJs(String month, String[] orgCodes, String... kmkCodeJs) throws ServiceException { if (StringUtils.isEmpty(month)) { throw new IllegalArgumentException("Can not find budget performance with given month is empty"); } if (ArrayUtils.isEmpty(orgCodes)) { throw new IllegalArgumentException( "Can not find budget performance with given organization code array is null"); } if (ArrayUtils.isEmpty(kmkCodeJs)) { throw new IllegalArgumentException( "Can not find budget performance with given kmkCodeJs array is null"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; Map<String, BudgetPerformanceBean> mapBudgetPerformances = new HashMap<String, BudgetPerformanceBean>(); try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder( "SELECT KmkCodeJ as kmkCodeJ, SUM(YosanKingaku) as yosanKingaku, SUM(JisekiKingaku) as jisekiKingaku "); sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE); sql.append(" WHERE StrCode IN (:orgCodes) "); sql.append(" AND GetSudo = :month "); sql.append(" AND KmkCodeJ IN (:kmkCodeJs) "); sql.append(" AND DelKbn = 2 "); sql.append(" GROUP BY Getsudo, KmkCodeJ"); Query query = repository.getSQLQuery(session, sql.toString()); query.setParameterList("orgCodes", orgCodes); query.setString("month", month); query.setParameterList("kmkCodeJs", kmkCodeJs); query.setResultTransformer(Transformers.aliasToBean(BudgetPerformanceBean.class)); List<BudgetPerformanceBean> budgetPerformances = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(budgetPerformances)) { throw new ObjectNotFoundException("No budget performance object found"); } for (BudgetPerformanceBean budgetPerformance : budgetPerformances) { mapBudgetPerformances.put(budgetPerformance.getKmkCodeJ(), budgetPerformance); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "Runtime exception occur when get a map of budget performance objects with given organization codes, kmkCodeJs and month", ex); } finally { HibernateSessionManager.closeSession(session); } return mapBudgetPerformances; }
From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w ww .j av a2 s. c o m public Map<String, BudgetPerformanceBean> findByOrgCodesAndPeriodMonthAndKmkCodeJs(List<String> orgCodes, String startMonth, String endMonth, String... kmkCodeJs) throws ServiceException { if (CollectionUtils.isEmpty(orgCodes)) { throw new IllegalArgumentException( "Organization codes or current month in acton must not be null or empty"); } if (StringUtils.isEmpty(startMonth)) { throw new IllegalArgumentException("Start month must not be null or empty"); } if (StringUtils.isEmpty(endMonth)) { throw new IllegalArgumentException("End month month must not be null or empty"); } if (ArrayUtils.isEmpty(kmkCodeJs)) { throw new IllegalArgumentException("KmkCodeJs must not be null"); } logger.info( "Get budgetperformance by organization codes:" + StringUtils.join(orgCodes, ",") + " startMonth " + startMonth + " endMonth " + endMonth + "kmkcodej " + StringUtils.join(kmkCodeJs, ",")); final Session session = HibernateSessionManager.getSession(); Transaction tx = null; Map<String, BudgetPerformanceBean> mapBudgetPerformances = new HashMap<String, BudgetPerformanceBean>(); try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder( "SELECT Getsudo as getSudo, KmkCodej as kmkCodeJ, SUM(YosanKingaku) as yosanKingaku,"); sql.append(" SUM(JisekiKingaku) as jisekiKingaku "); sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE); sql.append(" WHERE StrCode IN (:strCode) "); sql.append(" AND Getsudo >= :startMonth AND Getsudo <= :endMonth "); sql.append(" AND KmkCodej IN (:kmkCodeJs)"); sql.append(" AND DelKbn = " + Constants.STATUS_ACTIVE); sql.append(" GROUP BY Getsudo, KmkCodej "); sql.append(" ORDER BY Getsudo"); Query query = repository.getSQLQuery(session, sql.toString()); query.setParameterList("strCode", orgCodes); query.setParameter("startMonth", startMonth); query.setParameter("endMonth", endMonth); query.setParameterList("kmkCodeJs", kmkCodeJs); query.setResultTransformer(Transformers.aliasToBean(BudgetPerformanceBean.class)); List<BudgetPerformanceBean> budgetPerformances = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(budgetPerformances)) { throw new ObjectNotFoundException("There is no the budget performance object"); } for (BudgetPerformanceBean budgetPerformance : budgetPerformances) { String key = budgetPerformance.getGetSudo() + budgetPerformance.getKmkCodeJ(); mapBudgetPerformances.put(key, budgetPerformance); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException( "An exception occured while get budget performance data by organization code " + orgCodes, ex); } finally { HibernateSessionManager.closeSession(session); } return mapBudgetPerformances; }
From source file:com.nec.harvest.service.impl.CashServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/* ww w.j av a 2s . com*/ @SuppressWarnings("unchecked") public List<CashBean> findByOrgCodeAndMonth(String orgCode, String monthly) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(monthly)) { throw new IllegalArgumentException("Monthly must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<CashBean> cashes = new ArrayList<>(); try { tx = session.beginTransaction(); Query query = repository.getSQLQuery(session, SqlConstants.SQL_FIND_CASH_BY_ORGANIZATION_AND_MONTH); query.setParameter("strCode", orgCode); query.setParameter("getSudo", monthly); query.setResultTransformer(Transformers.aliasToBean(CashBean.class)); cashes = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(cashes)) { throw new ObjectNotFoundException( "Could not find any object in monthly " + monthly + " for the organization " + orgCode); } } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while get cash data ", ex); } finally { HibernateSessionManager.closeSession(session); } return cashes; }
From source file:com.nec.harvest.service.impl.ConsumptionTaxRateServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override//from www . j av a2 s. c o m public Map<String, Double> findRateDefByMonth(Date monthly) { if (monthly == null) { throw new IllegalArgumentException("date must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; TreeMap<String, Double> rateDefs = new TreeMap<String, Double>(); try { tx = session.beginTransaction(); Query query = repository.getQuery(session, " SELECT a.enfDate as enfDate, a.rateDef * 0.01 as rateDef " + " FROM ConsumptionTaxRate a " + " WHERE a.enfDate < ? " + " AND a.enfDate >= ? " + " AND a.delKbn = ? " + " ORDER BY a.enfDate "); String nextMonth = BusinessDayHelper.getNextMonthly(monthly, DateFormat.DATE_WITHOUT_DAY); // Set parameters for the given query SimpleDateFormat format = new SimpleDateFormat(DateFormat.DATE_WITHOUT_DAY.getFormatPattern()); Calendar beginDate = Calendar.getInstance(); beginDate.setTime(format.parse(nextMonth)); query.setParameter(0, beginDate); // Added a end of date for the query Calendar endDate = Calendar.getInstance(); endDate.setTime(monthly); query.setParameter(1, endDate); query.setParameter(2, Constants.STATUS_ACTIVE); query.setResultTransformer(Transformers.aliasToBean(ConsumptionTaxRate.class)); List<ConsumptionTaxRate> result = repository.findByQuery(query); query = repository.getQuery(session, " SELECT b.enfDate as enfDate, b.rateDef * 0.01 as rateDef FROM ConsumptionTaxRate b " + " WHERE b.enfDate = " + " (SELECT MAX(c.enfDate) " + " FROM ConsumptionTaxRate c WHERE c.enfDate < ? ) " + " AND b.delKbn = ? " + " ORDER BY b.enfDate "); beginDate.setTime(monthly); query.setParameter(0, beginDate).setParameter(1, Constants.STATUS_ACTIVE); query.setResultTransformer(Transformers.aliasToBean(ConsumptionTaxRate.class)); if (CollectionUtils.isEmpty(result)) { result = repository.findByQuery(query); } else { result.addAll(repository.findByQuery(query)); } format = new SimpleDateFormat("dd/MM/yyyy"); if (result != null) { for (ConsumptionTaxRate objs : result) { if (objs.getEnfDate() != null && objs.getRateDef() != null) { rateDefs.put(format.format((objs.getEnfDate()).getTime()), objs.getRateDef()); } } } tx.commit(); } catch (HibernateException | NullPointerException | ParseException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while query get rateDef ", ex); } finally { HibernateSessionManager.closeSession(session); } return rateDefs; }
From source file:com.nec.harvest.service.impl.FixedSystemCostServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from ww w .jav a 2 s . com*/ @SuppressWarnings("unchecked") public List<FixedSystemCostBean> findByOrgCodeAndMonth(String orgCode, String monthly, boolean isCopying) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(monthly)) { throw new IllegalArgumentException("Monthly must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<FixedSystemCostBean> fixedSystemCosts = new ArrayList<>(); try { StringBuffer sql; if (!isCopying) { sql = new StringBuffer("SELECT a.RecID as recID, a.KmkCode as kmkCode, a.ShoriKbn as shoriKbn,"); sql.append( " a.Tekiyo as tekiyo, a.HSKbn as hsKbn, a.kingaku as kingaku, a.UpdNo as updNo, ( SELECT d.kmkNameR FROM AT106 d WHERE d.DelKbn = :delKbn AND d.KmkCode = a.kmkCode) as kmkNameR"); sql.append(" FROM AT017 a WHERE a.Getsudo =:getSudo and a.StrCode =:strCode AND a.DelKbn = 2"); sql.append(" ORDER BY HSKbn ASC, KmkCode ASC"); } else { sql = new StringBuffer("SELECT a.RecID as recID, a.KmkCode as kmkCode, a.ShoriKbn as shoriKbn,"); sql.append( " a.Tekiyo as tekiyo, a.HSKbn as hsKbn, a.kingaku as kingaku, a.UpdNo as updNo, ( SELECT d.kmkNameR FROM AT106 d WHERE d.DelKbn = :delKbn AND d.KmkCode = a.kmkCode) as kmkNameR"); sql.append( " FROM AT017 a WHERE a.Getsudo =:getSudo and a.StrCode =:strCode AND a.DelKbn = 2 AND HSKbn = 1"); sql.append(" ORDER BY HSKbn ASC, KmkCode ASC"); } tx = session.beginTransaction(); // Query query = fixedSystemCostRepository.getSQLQuery(session, sql.toString()); query.setParameter("delKbn", Constants.DEFAULT_DEL_KBN); query.setParameter("strCode", orgCode); query.setParameter("getSudo", monthly); query.setResultTransformer(Transformers.aliasToBean(FixedSystemCostBean.class)); // fixedSystemCosts = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(fixedSystemCosts)) { throw new ObjectNotFoundException( "Could not find any object in monthly " + monthly + " for the organization " + orgCode); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.commit(); } throw new ServiceException("An exception occured while get data ", ex); } finally { HibernateSessionManager.closeSession(session); } return fixedSystemCosts; }
From source file:com.nec.harvest.service.impl.InventoryServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override//w w w. j av a 2 s. c o m public List<InventoryBean> findByOrgCodeAndMonth(String orgCode, String monthly) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(monthly)) { throw new IllegalArgumentException("Monthly must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<InventoryBean> inventories = new ArrayList<>(); try { tx = session.beginTransaction(); StringBuffer sql = new StringBuffer( "SELECT a.CtgCode as ctgCode, a.Kingaku as kingaku, a.UpdNo as updNo, b.CtgNameR as ctgName FROM "); sql.append( " AT015 a, AT114 b WHERE a.Getsudo =:getSudo and a.StrCode =:strCode AND a.CtgCode = b.CtgCode "); sql.append(" AND a.DelKbn = 2 ORDER BY ctgCode ASC"); // Query query = repository.getSQLQuery(session, sql.toString()); query.setParameter("strCode", orgCode); query.setParameter("getSudo", monthly); query.setResultTransformer(Transformers.aliasToBean(InventoryBean.class)); inventories = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(inventories)) { throw new ObjectNotFoundException( "Could not find any object in monthly " + monthly + " for the organization " + orgCode); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while get inventory data ", ex); } finally { HibernateSessionManager.closeSession(session); } return inventories; }
From source file:com.nec.harvest.service.impl.InventoryServiceImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from www .ja v a 2 s. co m*/ public List<InventoryBean> findByOrgCodeAndMonthAndBunruiKbn(String orgCode, String monthly, String bunruiKbn) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(monthly)) { throw new IllegalArgumentException("Monthly must not be null or empty"); } if (StringUtils.isEmpty(bunruiKbn)) { throw new IllegalArgumentException("BunruiKbn must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; List<InventoryBean> inventories = new ArrayList<>(); try { tx = session.beginTransaction(); StringBuffer sql = new StringBuffer( "SELECT a.CtgCode as ctgCode, a.Kingaku as kingaku, a.UpdNo as updNo, b.CtgNameR as ctgName FROM "); sql.append( " AT015 a, AT114 b WHERE a.Getsudo =:getSudo and a.StrCode =:strCode AND a.CtgCode = b.CtgCode AND b.BunruiKbn = :bunruiKbn "); sql.append(" AND a.DelKbn = 2 AND b.DelKbn = 2 ORDER BY ctgCode ASC"); // Query query = repository.getSQLQuery(session, sql.toString()); query.setParameter("strCode", orgCode); query.setParameter("getSudo", monthly); query.setParameter("bunruiKbn", bunruiKbn); query.setResultTransformer(Transformers.aliasToBean(InventoryBean.class)); inventories = query.list(); // Release transaction tx.commit(); if (CollectionUtils.isEmpty(inventories)) { throw new ObjectNotFoundException( "Could not find any object in monthly " + monthly + " for the organization " + orgCode); } } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while get inventory data ", ex); } finally { HibernateSessionManager.closeSession(session); } return inventories; }