List of usage examples for org.hibernate Query setResultTransformer
@Deprecated Query<R> setResultTransformer(ResultTransformer transformer);
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listRequerimentoByStatusMap(RequerimentoStatusEnum status) { Query query = this.sessionFactory.getCurrentSession() .createSQLQuery("select u.email, r.tiporequerimento as requerimento, r.status from requerimento r\n" + "join usuario u on u.id=r.usuario_id\n" + "where status = :status"); query.setString("status", status.name()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listUsuarioMap(PerfilEnum tipoPerfil, Curso curso) { Query query = this.sessionFactory.getCurrentSession() .createSQLQuery("select u.matricula, u.nome, c.nome as curso, u.email, p.tipoperfil\n" + "from usuario u\n" + "join perfil p on p.usuario_id=u.id\n" + "full outer join curso c on p.curso_id=c.id\n" + "where p.tipoperfil = :tipoPerfil\n" + (curso == null ? "" : "and c.id = :cursoId\n") + "order by c.nome asc, u.nome asc;"); if (curso != null) { query.setLong("cursoId", curso.getId()); }/*from w ww. j av a2s. c o m*/ query.setString("tipoPerfil", tipoPerfil.name()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:ca.qc.cegepoutaouais.tge.pige.server.ManagementServiceImpl.java
License:Open Source License
@Override public PagingLoadResult<Item> getItems(PagingLoadConfig configs) throws PigeException { PermissionHelper.checkBrowseInventoryPermission(getThreadLocalRequest()); Transaction tx = null;/* ww w . j a v a 2s. c o m*/ List<Item> items = null; Session session = null; Integer itemCount = 0; Integer offset = 0; Integer limit = 0; try { session = PigeHibernateUtil.openSession(); tx = session.beginTransaction(); //Date startDate = null; //Date endDate = null; List<FilterConfig> searchConfigs = configs.get(PIGE.SEARCH_CONFIGS); List<FilterConfig> fieldsConfigs = configs.get(PIGE.ITEM_FIELDS_CONFIGS); List<FilterConfig> stateConfigs = configs.get(PIGE.ITEM_STATE_CONFIGS); // Paramtres de recherche. Boolean requireAnd = Boolean.FALSE; Boolean includeAllCategories = Boolean.FALSE; String keyword = ""; if (searchConfigs != null) { Iterator<FilterConfig> itr = searchConfigs.iterator(); FilterConfig fc; while (itr.hasNext()) { fc = itr.next(); if (fc.getField().equals(PIGE.KEYWORD)) { keyword = (String) fc.getValue(); logger.debug("Extracting keyword: [" + keyword + "]..."); } else if (fc.getField().equals(PIGE.INCLUDE_ALL_CATEGORIES)) { includeAllCategories = (Boolean) fc.getValue(); logger.debug("Extracting includeAllCategories: [" + includeAllCategories + "]..."); } } } String query = "from Item as i"; String path; FilterConfig catfc = (FilterConfig) configs.get("category"); logger.debug("Testing category filtering..."); if (catfc != null && !includeAllCategories) { logger.debug("Extracting category object..."); Object object = catfc.getValue(); if (object != null && object instanceof Category) { logger.debug("Casting category object..."); Category category = (Category) object; if (category.getId() != Category.UNCLASSIFIED_CATEGORY_ID) { logger.debug("PATH = " + category.getPath()); path = prepareStringForQuery(category.getPath()); query += " left join i.categories as c " + "where c.path like '" + path + "%'"; } else { query += " where i.categories.size = 0"; } requireAnd = Boolean.TRUE; } } Boolean atLeastOneCriterion = Boolean.FALSE; StringBuilder searchQuery = new StringBuilder("("); FilterConfig fc; if (fieldsConfigs != null && fieldsConfigs.size() > 0 && keyword != null && !keyword.isEmpty()) { ListIterator<FilterConfig> itr = fieldsConfigs.listIterator(); String field; Boolean firstCriterion = Boolean.TRUE; while (itr.hasNext()) { fc = itr.next(); if ((Boolean) fc.getValue()) { atLeastOneCriterion = Boolean.TRUE; if (firstCriterion) { firstCriterion = Boolean.FALSE; } else { searchQuery.append(" or "); } field = (String) fc.getField(); if (field.equals(Item.QUANTITY_REF)) { String mathQuery = parseMathComparisonQuery(keyword); if (mathQuery != null) { searchQuery.append(mathQuery); } else { searchQuery.append("i.").append(field).append(" like '%").append(keyword) .append("%'"); } } else { searchQuery.append("i.").append(field).append(" like '%").append(keyword).append("%'"); } } } if (atLeastOneCriterion) { searchQuery.append(")"); query += (requireAnd ? " and " : " where "); query += searchQuery.toString(); requireAnd = Boolean.TRUE; } } atLeastOneCriterion = Boolean.FALSE; searchQuery = new StringBuilder("("); if (stateConfigs != null && stateConfigs.size() > 0) { ListIterator<FilterConfig> itr = stateConfigs.listIterator(); String field; Boolean firstCriterion = Boolean.TRUE; while (itr.hasNext()) { fc = itr.next(); if ((Boolean) fc.getValue()) { atLeastOneCriterion = Boolean.TRUE; if (firstCriterion) { firstCriterion = Boolean.FALSE; } else { searchQuery.append(" or "); } field = (String) fc.getField(); searchQuery.append("i.status='").append(field).append("'"); } } if (atLeastOneCriterion) { searchQuery.append(")"); query += (requireAnd ? " and " : " where "); query += searchQuery.toString(); } } Query itemQuery = session.createQuery("select count(*) " + query); itemQuery.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); itemCount = ((Long) itemQuery.iterate().next()).intValue(); offset = configs.getOffset(); limit = itemCount; if (limit > 0 && configs.getLimit() > 0) { limit = Math.min(configs.getLimit(), limit); } logger.debug("Paramtres d'extraction des donnes: dpart=" + offset + ", max=" + limit + "] ..."); items = session.createQuery("select i " + query + " order by i.name asc") .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).setFirstResult(offset).setMaxResults(limit) .list(); tx.commit(); logger.debug("Rcupration russie!"); } catch (Exception hex) { logger.error(hex); if (tx != null) { tx.rollback(); } } finally { if (session != null) { session.close(); } } if (items == null) { items = new ArrayList(); } return new BasePagingLoadResult(items, offset, itemCount); }
From source file:cc.cnfc.core.orm.hibernate.SimpleHibernateDao.java
License:Open Source License
/** * Querydistinct transformer./* w w w . j ava2 s . c om*/ */ public Query distinct(Query query) { query.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); return query; }
From source file:ch.algotrader.dao.AbstractDao.java
License:Open Source License
private Query createLoadAllQuery() { Session currentSession = getCurrentSession(); Query query = currentSession.createQuery("from " + this.entityClass.getSimpleName()); query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return query; }
From source file:cn.com.sinosoft.cimp.recordsummarize.datadeduplication.service.impl.DataDeduplicationService.java
public Integer findTotalPage(String sql, String crCode, String boxT, List<Map<String, Object>> params) { StringBuffer finalSql = new StringBuffer(); StringBuffer sb = new StringBuffer(); String colTableName = ""; StringBuffer temp = new StringBuffer(); colTableName = queryCreditItemTableFieldName( "select CODE_COLLECTION_TABLE from dic_credit_record_management where cr_code='" + crCode + "'"); // String s1 = colTableName.substring(8); // String s2 = "CIMP_"+s1; // sql = sql.replace(s2, colTableName); String ruleMin = "";//?? String ruleMax = "";//?? if (boxT != null && boxT.length() > 0) { ruleMin = boxT.split(",")[0]; ruleMax = boxT;//ww w . j a v a 2 s . c o m sb.append("select t.* from " + colTableName + " t where " + ruleMin); sb.append(" in (select c." + ruleMin + " from " + colTableName + " c where c.state_valid = '02' "); if (colTableName.equals("CIMP_CO_FOOD_LICENSE")) { if (crCode.equals("0103000000")) { sb.append(" and c.product_type like '?' "); } if (crCode.equals("0104000000")) { sb.append(" and c.product_type like '???' "); } if (crCode.equals("0105000000")) { sb.append(" and c.product_type like '????' "); } if (crCode.equals("0106000000")) { sb.append(" and c.product_type like '?' "); } } if (colTableName.equals("CIMP_CO_WATER")) { if (crCode.equals("0111000000")) {// sb.append(" and c.comp_type like '0203%' "); } } if (colTableName.equals("CIMP_CO_DISCIPLINE")) { if (crCode.equals("0201010000")) {//??? sb.append(" and c.specialty_primary like '01%' "); } if (crCode.equals("0206080000")) {//??? sb.append(" and c.specialty_primary like '08%' "); } if (crCode.equals("0207020000")) {//?????? sb.append(" and c.specialty_primary like '0203%' "); } if (crCode.equals("0203050000")) {//??? sb.append(" and c.specialty_primary like '05%' "); } if (crCode.equals("0204030000")) {//?)??? sb.append(" and c.specialty_primary like '03%' "); } if (crCode.equals("0205040000")) {//??? sb.append(" and c.specialty_primary like '04%' "); } if (crCode.equals("0208070000")) {//???---??like '07%' sb.append(" and c.specialty_primary like '07%' "); } if (crCode.equals("0202020000")) {//??? sb.append(" and c.specialty_primary like '02%' "); } } // sb.append(" group by "+ruleMax+" having count(1) > 1) and state_valid = '02' order by "+ruleMin); sb.append(" group by " + ruleMax + " having count(1) > 1) and state_valid = '02' "); if (colTableName.equals("CIMP_CO_FOOD_LICENSE")) { if (crCode.equals("0103000000")) { sb.append(" and t.product_type like '?' "); } if (crCode.equals("0104000000")) { sb.append(" and t.product_type like '???' "); } if (crCode.equals("0105000000")) { sb.append(" and t.product_type like '????' "); } if (crCode.equals("0106000000")) { sb.append(" and t.product_type like '?' "); } } if (colTableName.equals("CIMP_CO_WATER")) { if (crCode.equals("0111000000")) {// sb.append(" and t.comp_type like '0203%' "); } } if (colTableName.equals("CIMP_CO_DISCIPLINE")) { if (crCode.equals("0201010000")) {//??? sb.append(" and t.specialty_primary like '01%' "); } if (crCode.equals("0206080000")) {//??? sb.append(" and t.specialty_primary like '08%' "); } if (crCode.equals("0207020000")) {//?????? sb.append(" and t.specialty_primary like '0203%' "); } if (crCode.equals("0203050000")) {//??? sb.append(" and t.specialty_primary like '05%' "); } if (crCode.equals("0204030000")) {//?)??? sb.append(" and t.specialty_primary like '03%' "); } if (crCode.equals("0205040000")) {//??? sb.append(" and t.specialty_primary like '04%' "); } if (crCode.equals("0208070000")) {//???---??like '07%' sb.append(" and t.specialty_primary like '07%' "); } if (crCode.equals("0202020000")) {//??? sb.append(" and t.specialty_primary like '02%' "); } } sb.append(" order by " + ruleMin); } if (!params.isEmpty() || params.size() != 0) { int sum = 0; temp.append(" select distinct "); temp.append(ruleMin); temp.append(" from ( "); temp.append(sb); temp.append(" ) where 1 =1 "); temp.append(sql); Query query = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(temp.toString()); if (params.size() != 0) {//-----------------------------------> for (Map<String, Object> map : params) { if (map.get("symbol").equals("R")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } else { if (map.get("fuzzy").equals("T")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), "%" + (String) entry.getValue() + "%"); } } } else { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } } } } List<String> obj = query.list(); if (obj.size() != 0) { String ruleStr = getSqlStrByList(obj, 999, ruleMin); // for(int i=0;i<obj.size();i++){ temp.delete(0, temp.length()); temp.append("select count(*) quantity from "); temp.append(colTableName); temp.append(" where "); // temp.append(ruleMin); // temp.append(" in (:obj) "); temp.append(ruleStr); temp.append(" and state_valid = '02' "); if (temp != null && temp.length() > 0) { Query qry = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(temp.toString()); // qry.setParameterList("obj", obj); qry.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); Map map = (Map) qry.list().get(0); BigDecimal b = (BigDecimal) map.get("QUANTITY"); sum = b.intValue(); } // } } return sum; } else { temp.append("select count(*) quantity from ( "); temp.append(sb); temp.append(" ) "); } // StringBuffer sbSql = new StringBuffer(getSql(sql,crCode,boxT)); // finalSql.append("select count(*) quantity from ( "); // finalSql.append(sbSql + " )"); if (temp != null && temp.length() > 0) { Query query = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(temp.toString()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); Map map = (Map) query.list().get(0); BigDecimal b = (BigDecimal) map.get("QUANTITY"); return b.intValue(); } return 0; }
From source file:cn.com.sinosoft.cimp.recordsummarize.datadeduplication.service.impl.DataDeduplicationService.java
public List<Map<String, Object>> findByPage(String sql, String crCode, String boxT, List<Map<String, Object>> params, String page, String rows) { // StringBuffer orignalSql = new StringBuffer(getSql(sql,crCode,boxT)); StringBuffer orignalSql = new StringBuffer(); StringBuffer finalSql = new StringBuffer(); StringBuffer sb = new StringBuffer(); StringBuffer temp = new StringBuffer(); String colTableName = queryCreditItemTableFieldName( "select CODE_COLLECTION_TABLE from dic_credit_record_management where cr_code='" + crCode + "'"); // String s1 = colTableName.substring(8); // String s2 = "CIMP_"+s1; // sql = sql.replace(s2, colTableName); String ruleMin = "";//?? String ruleMax = "";//?? String coltable = dao// www. j av a 2 s. co m .executeSql("SELECT T.QUERY_COL_RELEASE_SQL FROM DIC_CREDIT_RECORD_MANAGEMENT T WHERE T.CR_CODE='" + crCode + "'"); if (boxT != null && boxT.length() > 0) { ruleMin = boxT.split(",")[0]; ruleMax = boxT; // sb.append("select t.* from "+colTableName+" t where "+ruleMin); sb.append(coltable + " and " + ruleMin); sb.append(" in (select c." + ruleMin + " from " + colTableName + " c where c.state_valid = '02' "); if (colTableName.equals("CIMP_CO_FOOD_LICENSE")) { if (crCode.equals("0103000000")) { sb.append(" and c.product_type like '?' "); } if (crCode.equals("0104000000")) { sb.append(" and c.product_type like '???' "); } if (crCode.equals("0105000000")) { sb.append(" and c.product_type like '????' "); } if (crCode.equals("0106000000")) { sb.append(" and c.product_type like '?' "); } } if (colTableName.equals("CIMP_CO_WATER")) { if (crCode.equals("0111000000")) {// sb.append(" and c.comp_type like '0203%' "); } } if (colTableName.equals("CIMP_CO_DISCIPLINE")) { if (crCode.equals("0201010000")) {//??? sb.append(" and c.specialty_primary like '01%' "); } if (crCode.equals("0206080000")) {//??? sb.append(" and c.specialty_primary like '08%' "); } if (crCode.equals("0207020000")) {//?????? sb.append(" and c.specialty_primary like '0203%' "); } if (crCode.equals("0203050000")) {//??? sb.append(" and c.specialty_primary like '05%' "); } if (crCode.equals("0204030000")) {//?)??? sb.append(" and c.specialty_primary like '03%' "); } if (crCode.equals("0205040000")) {//??? sb.append(" and c.specialty_primary like '04%' "); } if (crCode.equals("0208070000")) {//???---??like '07%' sb.append(" and c.specialty_primary like '07%' "); } if (crCode.equals("0202020000")) {//??? sb.append(" and c.specialty_primary like '02%' "); } } // sb.append(" group by "+ruleMax+" having count(1) > 1) and state_valid = '02' order by "+ruleMin); sb.append(" group by " + ruleMax + " having count(1) > 1) and state_valid = '02' "); if (colTableName.equals("CIMP_CO_FOOD_LICENSE")) { if (crCode.equals("0103000000")) { sb.append(" and product_type like '?' "); } if (crCode.equals("0104000000")) { sb.append(" and product_type like '???' "); } if (crCode.equals("0105000000")) { sb.append(" and product_type like '????' "); } if (crCode.equals("0106000000")) { sb.append(" and product_type like '?' "); } } if (colTableName.equals("CIMP_CO_WATER")) { if (crCode.equals("0111000000")) {// sb.append(" and comp_type like '0203%' "); } } if (colTableName.equals("CIMP_CO_DISCIPLINE")) { if (crCode.equals("0201010000")) {//??? sb.append(" and specialty_primary like '01%' "); } if (crCode.equals("0206080000")) {//??? sb.append(" and specialty_primary like '08%' "); } if (crCode.equals("0207020000")) {//?????? sb.append(" and specialty_primary like '0203%' "); } if (crCode.equals("0203050000")) {//??? sb.append(" and specialty_primary like '05%' "); } if (crCode.equals("0204030000")) {//?)??? sb.append(" and specialty_primary like '03%' "); } if (crCode.equals("0205040000")) {//??? sb.append(" and specialty_primary like '04%' "); } if (crCode.equals("0208070000")) {//???---??like '07%' sb.append(" and specialty_primary like '07%' "); } if (crCode.equals("0202020000")) {//??? sb.append(" and specialty_primary like '02%' "); } } sb.append(" order by " + ruleMin); } if (!params.isEmpty() || params.size() != 0) { temp.append(" select "); temp.append(ruleMin); temp.append(" from ( "); temp.append(sb); temp.append(" ) where 1 = 1 "); temp.append(sql); Query query = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(temp.toString()); if (params.size() != 0) {//-----------------------------------> for (Map<String, Object> map : params) { if (map.get("symbol").equals("R")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } else { if (map.get("fuzzy").equals("T")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), "%" + (String) entry.getValue() + "%"); } } } else { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } } } } List<String> obj = query.list(); if (obj.size() != 0) { String ruleStr = getSqlStrByList(obj, 999, ruleMin); finalSql.append("SELECT * "); // finalSql.append(" * "); finalSql.append(" FROM ( "); finalSql.append(" SELECT ORINGAL.*, ROWNUM rnum "); // finalSql.append(" ORINGAL.*, ROWNUM rnum "); finalSql.append(" FROM ( "); // finalSql.append(" select * from "+colTableName+" where "+ruleMin+" in (:obj) and state_valid='02' order by "+ruleMax+"");//---------- finalSql.append(" select * from ( " + sb + " ) where " + ruleStr + " and state_valid='02' order by " + ruleMax); finalSql.append(" ) ORINGAL"); finalSql.append(" WHERE ROWNUM <= " + Integer.parseInt(page) * (Integer.parseInt(rows))); finalSql.append(" ) "); finalSql.append(" WHERE "); finalSql.append(" rnum > " + (Integer.parseInt(page) - 1) * (Integer.parseInt(rows))); Query qry = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(finalSql.toString()); // qry.setParameterList("obj", obj); qry.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); DataHandleUtil u = new DataHandleUtil(); List<Map<String, Object>> newItems = u.idCardHandlerItem(qry.list(), "ID_CARD"); return newItems; } return new ArrayList<Map<String, Object>>(); } else { finalSql.append("SELECT"); finalSql.append(" * "); finalSql.append(" FROM ( "); finalSql.append(" SELECT "); finalSql.append(" ORINGAL.*, ROWNUM rnum "); finalSql.append(" FROM ( "); finalSql.append(sb); finalSql.append(" ) ORINGAL"); finalSql.append(" ) "); finalSql.append(" WHERE "); finalSql.append(" rnum > " + (Integer.parseInt(page) - 1) * (Integer.parseInt(rows))); finalSql.append(" AND rnum <= " + Integer.parseInt(page) * (Integer.parseInt(rows))); Query query = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(finalSql.toString()); if (params.size() != 0) { for (int i = 0; i < params.size(); i++) { Map<String, Object> map = params.get(i); if (map.get("symbol").equals("R")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } else { if (map.get("fuzzy").equals("T")) { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), "%" + (String) entry.getValue() + "%"); } } } else { for (Entry<String, Object> entry : map.entrySet()) { if (!(entry.getKey().equals("fuzzy") || entry.getKey().equals("symbol"))) { query.setString(entry.getKey(), (String) entry.getValue()); } } } } } } query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); DataHandleUtil u = new DataHandleUtil(); List<Map<String, Object>> newItems = u.idCardHandlerItem(query.list(), "ID_CARD"); return newItems; } }
From source file:cn.com.sinosoft.cimp.recordsummarize.datadeduplication.service.impl.DataDeduplicationService.java
public List<Map<String, Object>> getCreditTypeByPermissions(String orgCode, String type) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); StringBuffer sql = new StringBuffer(); sql.append("SELECT "); sql.append(" * "); sql.append(" FROM "); sql.append(" DIC_CREDIT_INFO_TYPE ORDER BY ORDERS"); Query query = hibernateTemplate.getSessionFactory().openSession().createSQLQuery(sql.toString()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); List<Map<String, Object>> list = query.list(); System.out.println("?" + orgCode); for (Map<String, Object> map : list) { String departments = (String) map.get("BELONG_DEPARTMENTS"); if (Arrays.asList(departments.split(",")).contains(orgCode)) { String typename = (String) map.get("NAME"); if (type.equals("1")) {//1??? 2 if (orgCode.equals("0000000001")) { if (!typename.isEmpty() && !typename.equals("????")) { result.add(map); }//from w ww .ja va2s. co m } else if (orgCode.equals("0000000000")) { if (!typename.isEmpty() && !typename.equals("?")) { result.add(map); } } else { result.add(map); } } if (type.equals("2")) { if (orgCode.equals("0000000001")) { if (!typename.isEmpty() && !typename.equals("????")) { result.add(map); } } else { result.add(map); } } } } result.get(0).put("selected", true); return result; }
From source file:cognition.pipeline.data.CoordinatesDao.java
License:Apache License
/** * * @return A list of all coordinates to be processed. Coordinates are retreieved * via the named-query "getCoordinates". *//*from w ww. j av a 2 s . c o m*/ public List<DNCWorkCoordinate> getCoordinates() { SessionWrapper session = createSourceSession(); try { Query getCoordinates = session.getNamedQuery("getCoordinates"); List<DNCWorkCoordinate> coordinateList = getCoordinates .setResultTransformer(Transformers.aliasToBean(DNCWorkCoordinate.class)).list(); return coordinateList; } catch (Exception ex) { logger.error("Error loading coordinates. Please check getCoordinates query. " + ex.getMessage()); return new ArrayList<>(); } finally { session.closeSession(); } }
From source file:com.age.core.orm.hibernate.HibernateDao.java
License:Apache License
public <X> Page<X> findPage(final PageRequest pageRequest, String hql, final Map<String, ?> values, Class<X> clasz) {//from www . ja v a 2s . co m AssertUtils.notNull(pageRequest, "pageRequest?"); Page<X> page = new Page<X>(pageRequest); if (pageRequest.isCountTotal()) { long totalCount = countHqlResult(hql, values); page.setTotalItems(totalCount); } Query q = createQuery(hql, values); q.setResultTransformer(new AliasToBeanResultTransformer(clasz)); setPageParameterToQuery(q, pageRequest); List result = q.list(); page.setResult(result); return page; }