List of usage examples for com.liferay.portal.kernel.dao.orm QueryUtil iterate
public static Iterator<?> iterate(Query query, Dialect dialect, int start, int end)
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected List<Object> doFindF_FE_FS_ByG_F_S_M_M(long groupId, long folderId, int status, String[] mimeTypes, boolean includeMountFolders, int start, int end, OrderByComparator obc, boolean inlineSQLHelper) throws SystemException { Session session = null;/*from w w w.j a v a 2s .c o m*/ try { session = openSession(); StringBundler sb = new StringBundler(7); sb.append("SELECT * FROM ("); String sql = CustomSQLUtil.get(FIND_F_BY_G_M_F); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFolder.class.getName(), "DLFolder.folderId", groupId); } sb.append(sql); sb.append(" UNION ALL "); if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(FIND_FE_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_FE_BY_G_F_S); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sb.append(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { for (int i = 0; i < mimeTypes.length; i++) { if (i == 0) { sb.append(" AND ("); } else { sb.append(" OR"); } sb.append(" DLFileEntry.mimeType = '"); sb.append(mimeTypes[i]); sb.append("'"); } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append(" UNION ALL "); sql = CustomSQLUtil.get(FIND_FS_BY_G_F_S); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(), "DLFileShortcut.fileShortcutId", groupId); } sb.append(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { for (int i = 0; i < mimeTypes.length; i++) { if (i == 0) { sb.append(" AND ("); } else { sb.append(" OR"); } sb.append(" mimeType = '"); sb.append(mimeTypes[i]); sb.append("'"); } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append(") TEMP_TABLE ORDER BY modelFolder DESC, title ASC"); sql = sb.toString(); if (includeMountFolders) { sql = StringUtil.replace(sql, "(DLFolder.mountPoint = ?) AND", ""); } sql = StringUtil.replace(sql, "[$FOLDER_PARENT_FOLDER_ID$]", getFolderId(folderId, "DLFolder")); sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry")); sql = StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut")); sql = CustomSQLUtil.replaceOrderBy(sql, obc); SQLQuery q = session.createSQLQuery(sql); q.addScalar("modelFolderId", Type.LONG); q.addScalar("name", Type.STRING); q.addScalar("title", Type.STRING); q.addScalar("fileShortcutId", Type.LONG); q.addScalar("modelFolder", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!includeMountFolders) { qPos.add(false); } qPos.add(folderId); qPos.add(groupId); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(folderId); qPos.add(groupId); qPos.add(folderId); List<Object> models = new ArrayList<Object>(); Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Object[] array = itr.next(); long curFolderId = (Long) array[0]; String name = (String) array[1]; //String title = (String)array[2]; long fileShortcutId = (Long) array[3]; long modelFolder = (Long) array[4]; Object obj = null; if (modelFolder == 1) { obj = DLFolderUtil.findByPrimaryKey(curFolderId); } else if (fileShortcutId > 0) { obj = DLFileShortcutUtil.findByPrimaryKey(fileShortcutId); } else { obj = DLFileEntryUtil.findByG_F_N(groupId, curFolderId, name); } models.add(obj); } return models; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected List<Object> doFindFE_FS_ByG_F_S(long groupId, long folderId, int status, int start, int end, boolean inlineSQLHelper) throws SystemException { Session session = null;//from w w w. j av a2 s . c o m try { session = openSession(); StringBundler sb = new StringBundler(5); sb.append("SELECT * FROM ("); String sql = null; if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(FIND_FE_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_FE_BY_G_F_S); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sb.append(sql); sb.append(" UNION ALL "); sql = CustomSQLUtil.get(FIND_FS_BY_G_F_S); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(), "DLFileShortcut.fileShortcutId", groupId); } sb.append(sql); sb.append(") TEMP_TABLE ORDER BY modelFolder DESC, title ASC"); sql = sb.toString(); sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry")); sql = StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut")); SQLQuery q = session.createSQLQuery(sql); q.addScalar("modelFolderId", Type.LONG); q.addScalar("name", Type.STRING); q.addScalar("title", Type.STRING); q.addScalar("fileShortcutId", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(folderId); qPos.add(groupId); qPos.add(folderId); List<Object> models = new ArrayList<Object>(); Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Object[] array = itr.next(); long folderId2 = (Long) array[0]; String name = (String) array[1]; //String title = (String)array[2]; long fileShortcutId = (Long) array[3]; Object obj = null; if (fileShortcutId > 0) { obj = DLFileShortcutUtil.findByPrimaryKey(fileShortcutId); } else { obj = DLFileEntryUtil.findByG_F_N(groupId, folderId2, name); } models.add(obj); } return models; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.social.service.persistence.SocialActivityFinderImpl.java
License:Open Source License
public List<SocialActivity> findByUserGroupsAndOrganizations(long userId, int start, int end) throws SystemException { Session session = null;//from w w w . java 2 s .com try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_USER_GROUPS_AND_ORGANIZATIONS); SQLQuery q = session.createSQLQuery(sql); q.addScalar("activityId", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(userId); List<SocialActivity> socialActivities = new ArrayList<SocialActivity>(); Iterator<Long> itr = (Iterator<Long>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Long activityId = itr.next(); SocialActivity socialActivity = SocialActivityUtil.findByPrimaryKey(activityId); socialActivities.add(socialActivity); } return socialActivities; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.dvc.service.persistence.ThuTucHanhChinhFinderImpl.java
License:Apache License
/** * This is fucntion search ThuTucHanhChinh by ungDungId, nhomId,param paging * Version: 1.0//from ww w . j av a 2 s . c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param Long ungDungId,Long nhomId,int start,int end * @return List<ThuTucHanhChinh> */ public List<ThuTucHanhChinh> searchByUngDungOrNhom(Long ungDungId, Long nhomId, int start, int end) throws SystemException { Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(""); sql.append( " SELECT tt.ID,tt.MA,tt.TEN,tt.TRANGTHAI,ungdung.MA as MAUNGDUNG FROM CMON_THUTUCHANHCHINH tt"); sql.append(" JOIN CMON_NHOMTHUTUCHANHCHINH nhom on nhom.id = tt.nhomthutuchanhchinhid"); sql.append(" join CMON_DANHMUCUNGDUNG ungdung on ungdung.id=nhom.danhmucungdungid"); sql.append(" WHERE tt.daXoa=0 "); if (ungDungId != null) { sql.append(" AND ungdung.id=? "); } if (nhomId != null) { sql.append(" AND nhom.id=? "); } sql.append(" ORDER BY tt.ten ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("ID", Type.LONG); q.addScalar("MA", Type.STRING); q.addScalar("TEN", Type.STRING); q.addScalar("TRANGTHAI", Type.INTEGER); q.addScalar("MAUNGDUNG", Type.STRING); QueryPos qPos = QueryPos.getInstance(q); if (ungDungId != null) { qPos.add(ungDungId); } if (nhomId != null) { qPos.add(nhomId); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); List<ThuTucHanhChinh> result = new ArrayList<ThuTucHanhChinh>(); while (itr.hasNext()) { try { Object[] a = itr.next(); ThuTucHanhChinh t = new ThuTucHanhChinhImpl(); t.setId((Long) a[0]); t.setMa((String) a[1]); t.setTen((String) a[2]); t.setTrangThai((Integer) a[3]); t.setNguoiTao((String) a[4]); result.add(t); } catch (Exception e) { // TODO: handle exception } } return result; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.dvc.service.persistence.ThuTucHanhChinhFinderImpl.java
License:Apache License
/** * This is fucntion search ThuTuc2GiayTo by tthcid, dgId,daXoa, param paging * Version: 1.0/* w w w. j a v a 2s. c o m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param Long tthcid, Long dgId, Integer daXoa, int start,int end * @return List<ThuTuc2GiayTo> */ public List<ThuTuc2GiayTo> searchByTTHCIdOrGDId(Long tthcid, Long dgId, Integer daXoa, int start, int end) throws SystemException { Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(""); sql.append(" SELECT tt2gt.id AS ID , gt.ten AS TEN, tt2gt.batbuoc AS BATBUOC, "); sql.append(" tt2gt.giaidoan AS GIAIDOAN, tt2gt.thutuhienthi AS THUTUHIENTHI, "); sql.append( " tt2gt.trangthai as TRANGTHAI, tt2gt.danhmucgiaytoid as danhmucgiaytoid, tt2gt.thutuchanhchinhid as thutuchanhchinhid "); sql.append(" FROM cmon_thutuc2giayto tt2gt "); sql.append(" Join cmon_danhmucgiayto gt on gt.id=tt2gt.danhmucgiaytoid"); sql.append(" Join cmon_thutuchanhchinh tthc on tthc.id=tt2gt.thutuchanhchinhid"); sql.append(" WHERE 1=1 "); if (tthcid != null) { sql.append(" AND tt2gt.thutuchanhchinhid=? "); } if (dgId != null) { sql.append(" AND tt2gt.giaidoan=? "); } if (daXoa != null) { sql.append(" AND tt2gt.daxoa=? "); } sql.append(" ORDER BY tt2gt.thutuhienthi ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("ID", Type.LONG); q.addScalar("TEN", Type.STRING); q.addScalar("BATBUOC", Type.INTEGER); q.addScalar("GIAIDOAN", Type.INTEGER); q.addScalar("THUTUHIENTHI", Type.LONG); q.addScalar("TRANGTHAI", Type.STRING); q.addScalar("danhmucgiaytoid", Type.LONG); q.addScalar("thutuchanhchinhid", Type.LONG); int queryPos = 0; if (tthcid != null) { q.setLong(queryPos++, tthcid); } if (dgId != null) { q.setLong(queryPos++, dgId); } if (daXoa != null) { q.setLong(queryPos++, daXoa); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); List<ThuTuc2GiayTo> result = new ArrayList<ThuTuc2GiayTo>(); while (itr.hasNext()) { Object[] a = itr.next(); ThuTuc2GiayTo t = new ThuTuc2GiayToImpl(); t.setId(Long.valueOf(a[0].toString())); t.setNguoiTao((String) a[1]); t.setBatBuoc(Integer.valueOf(a[2].toString())); t.setGiaidoan(Integer.valueOf(a[3].toString())); t.setThuTuHienThi(Long.valueOf(a[4].toString())); t.setTrangThai(Integer.parseInt(a[5].toString())); t.setDanhMucGiayToId(Long.valueOf(a[6].toString())); t.setThuTucHanhChinhId(Long.valueOf(a[7].toString())); result.add(t); } return result; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.dvc.service.persistence.ThuTucHanhChinhFinderImpl.java
License:Apache License
/** * This is fucntion search VanBanHuongDan by tthcid, loaiTL,daXoa,param paging * Version: 1.0//from w ww. ja va 2 s.c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String : Long tthcid, Long loaiTL, Integer daXoa, int start,int end * @return List<VanBanHuongDan> */ public List<VanBanHuongDan> searchByTTHC2HDBM(Long tthcid, Long loaiTL, Integer daXoa, int start, int end) throws SystemException { Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(""); sql.append( " SELECT vb.id as ID, vb.tentailieu as tentailieu, vb.loaitailieu as loaitailieu, vb.noiluutruid as noiluutruid, vb.thutuchanhchinhid as thutuchanhchinhid from cmon_vanbanhuongdan vb"); sql.append(" Join cmon_thutuchanhchinh tthc on tthc.id=vb.thutuchanhchinhid"); sql.append(" WHERE 1=1 "); if (tthcid != null) { sql.append(" AND vb.thutuchanhchinhid=? "); } if (loaiTL != null) { sql.append(" AND vb.loaitailieu=? "); } if (daXoa != null) { sql.append(" AND vb.daxoa=? "); } sql.append(" ORDER BY vb.tentailieu ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("ID", Type.LONG); q.addScalar("tentailieu", Type.STRING); q.addScalar("loaitailieu", Type.LONG); q.addScalar("noiluutruid", Type.LONG); q.addScalar("thutuchanhchinhid", Type.LONG); int queryPos = 0; if (tthcid != null) { q.setLong(queryPos++, tthcid); } if (loaiTL != null) { q.setLong(queryPos++, loaiTL); } if (daXoa != null) { q.setLong(queryPos++, daXoa); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); List<VanBanHuongDan> result = new ArrayList<VanBanHuongDan>(); while (itr.hasNext()) { Object[] a = itr.next(); VanBanHuongDan t = new VanBanHuongDanImpl(); t.setId(Long.valueOf(a[0].toString())); t.setTenTaiLieu((String) a[1]); t.setLoaiTaiLieu(Long.valueOf(a[2].toString())); t.setNoiLuuTruId(Long.valueOf(a[3].toString())); t.setThuTucHanhChinhId(Long.valueOf(a[4].toString())); result.add(t); } return result; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.hosohcc.service.persistence.FileDinhKemFinderImpl.java
License:Apache License
/** * This is fucntion findNoiLuuTruFileTraKetQua * Version: 1.0//from ww w .j av a 2 s. c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long hoSoTTHCCongId * @return Long */ public Long findNoiLuuTruFileTraKetQua(long hoSoTTHCCongId) throws SystemException { // / This stuff is basic set up Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(); sql.append("SELECT luutru.noiluutruid as ID FROM CMON_GIAYTODINHKEMHOSO dinhkem"); sql.append(" JOIN CMON_THUTUC2GIAYTO tt2gt on tt2gt.id=dinhkem.thutuc2giaytoid"); sql.append(" JOIN CMON_NOILUUTRUTAILIEU luutru on luutru.id=dinhkem.noiluutrutailieuid"); sql.append(" WHERE tt2gt.daxoa= ?"); sql.append(" AND tt2gt.giaidoan= ?"); sql.append(" AND dinhkem.hosotthccongid = ?"); SQLQuery q = session.createSQLQuery(sql.toString()); QueryPos qPos = QueryPos.getInstance(q); qPos.add(org.oep.sharedservice.cmon.Constants.ACTIVATED); qPos.add(org.oep.sharedservice.cmon.Constants.STEP.STEP3); qPos.add(hoSoTTHCCongId); Iterator<Object> itr = (Iterator<Object>) QueryUtil.iterate(q, getDialect(), 0, 1); while (itr.hasNext()) { BigDecimal a = (BigDecimal) itr.next(); return a.longValue(); } } catch (Exception e) { throw new SystemException(e); } finally { // must have this to close the hibernate session.. // if you fail to do this.. you will have a lot of open sessions closeSession(session); } return null; }
From source file:org.oep.cmon.dao.nsd.service.persistence.TaiNguyenFinderImpl.java
License:Apache License
/** * This is fucntion searchByVaiTroId //w w w .jav a 2 s . co m * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param Long vaiTroId, int daXoa, int start, int end * @return List<TaiNguyen> */ public List<TaiNguyen> searchByVaiTroId(Long vaiTroId, int daXoa, int start, int end) throws SystemException { Session session = null; List<TaiNguyen> list = new ArrayList<TaiNguyen>(); try { session = openSession(); StringBuffer sql = new StringBuffer(""); sql.append( " Select distinct tn.id, tn.ten, tn.ungdungid, tn.hethongid, tn.loai from cmon_tainguyen tn "); sql.append(" LEFT JOIN cmon_tainguyen2vaitro tn2vt ON tn2vt.tainguyenid=tn.ID "); sql.append(" LEFT JOIN cmon_vaitro vt ON vt.ID=tn2vt.vaitroid "); sql.append(" WHERE 1=1 "); if (vaiTroId != null) { sql.append(" AND tn2vt.vaitroid=? "); } if (Validator.isNotNull(daXoa)) { sql.append(" AND tn.daxoa=? "); } sql.append(" ORDER BY tn.ten ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("ID", Type.LONG); q.addScalar("TEN", Type.STRING); q.addScalar("UNGDUNGID", Type.LONG); q.addScalar("HETHONGID", Type.LONG); q.addScalar("LOAI", Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(vaiTroId)) { qPos.add(vaiTroId); } if (Validator.isNotNull(daXoa)) { qPos.add(daXoa); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Object[] a = itr.next(); TaiNguyen t = new TaiNguyenImpl(); t.setId(Long.valueOf(a[0].toString())); t.setTen((String) a[1]); t.setUngDungId(Long.valueOf(a[2].toString())); t.setHeThongId(Long.valueOf(a[3].toString())); t.setLoai(Integer.valueOf(a[4].toString())); list.add(t); } return list; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.oep.cmon.dao.qlhc.service.persistence.CoQuanQuanLyFinderImpl.java
License:Apache License
/** * This is fucntion getDSCoQuanQuanlyByDonViHanhChinhId * Version: 1.0//from w w w. j a v a 2s.c om * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String donviHanhChinhIds * @return List<CoQuanQuanLy> */ public List<CoQuanQuanLy> getDSCoQuanQuanlyByDonViHanhChinhId(String donviHanhChinhIds) { Session session = null; StringBuffer sql = new StringBuffer(); try { session = openSession(); sql.append("SELECT cq.id,cq.ma,cq.ten FROM CMON_COQUANQUANLY cq"); sql.append(" WHERE cq.daXoa=0 AND cq.donvihanhchinhid in(" + donviHanhChinhIds + ")"); sql.append(" ORDER BY cq.ten ASC "); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("ID", Type.LONG); q.addScalar("MA", Type.STRING); q.addScalar("TEN", Type.STRING); Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); List<CoQuanQuanLy> result = new ArrayList<CoQuanQuanLy>(); while (itr.hasNext()) { try { Object[] a = itr.next(); CoQuanQuanLy t = new CoQuanQuanLyImpl(); t.setId((Long) a[0]); t.setMa((String) a[1]); t.setTen((String) a[2]); result.add(t); } catch (Exception e) { // TODO: handle exception } } return result; } catch (Exception e) { e.printStackTrace(); } finally { closeSession(session); } return null; }
From source file:org.oep.cmon.dao.thamso.service.persistence.AnhXaFinderImpl.java
License:Apache License
/** * This is fucntion getDSByTenOrMa//from www. java 2 s . co m * Version: 1.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String table,String code,String ten * @return List<AnhXa> */ public List<AnhXa> getDSByTenOrMa(String table, String code, String ten) { Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(""); sql.append(" SELECT id,ma,ten FROM " + table); sql.append(" WHERE daXoa=0 "); if (code != null && code.trim().length() > 0) { sql.append(" AND LOWER(ma)=LOWER(?) "); } if (ten != null && ten.trim().length() > 0) { sql.append(" AND LOWER(ten)= LOWER(?) "); } sql.append(" ORDER BY LOWER(id) DESC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.addScalar("id", Type.LONG); q.addScalar("ma", Type.STRING); q.addScalar("ten", Type.STRING); QueryPos qPos = QueryPos.getInstance(q); if (code != null && code.trim().length() > 0) { qPos.add(code); } if (ten != null && ten.trim().length() > 0) { qPos.add(ten); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); List<AnhXa> result = new ArrayList<AnhXa>(); while (itr.hasNext()) { Object[] a = itr.next(); AnhXa t = new AnhXaImpl(); t.setId((Long) a[0]); t.setMaDNG((String) a[1]); t.setTenDNG((String) a[2]); result.add(t); } return result; } catch (Exception e) { } finally { closeSession(session); } return null; }