List of usage examples for com.liferay.portal.kernel.dao.orm SQLQuery setCacheable
public Query setCacheable(boolean cacheable);
From source file:com.liferay.social.activity.customizer.service.persistence.impl.CustomSocialActivitySetFinderImpl.java
License:Open Source License
public int countByU_C(long userId, long classNameId) { Session session = null;/*from www. jav a2 s . c o m*/ try { session = CustomFinderHelperUtil.openPortalSession(); String sql = CustomSQLUtil.get(CustomSocialActivitySetFinderImpl.class, COUNT_BY_USERID_CLASSNAMEID); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setCacheable(false); q.addEntity("SocialActivitySet", CustomFinderHelperUtil.getImplClass( "com.liferay.portlet.social.model.impl." + "SocialActivitySetImpl", PortalClassLoaderUtil.getClassLoader())); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { try { throw new SystemException(e); } catch (SystemException se) { se.printStackTrace(); } } finally { closeSession(session); } return 0; }
From source file:com.liferay.social.activity.customizer.service.persistence.impl.CustomSocialActivitySetFinderImpl.java
License:Open Source License
public int countByU_C_T(long userId, long classNameId, long[] types) { Session session = null;//from w w w . j a va2 s . com try { session = CustomFinderHelperUtil.openPortalSession(); String sql = CustomSQLUtil.get(CustomSocialActivitySetFinderImpl.class, COUNT_BY_USERID_CLASSNAMEID_TYPE); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setCacheable(false); q.addEntity("SocialActivitySet", CustomFinderHelperUtil.getImplClass( "com.liferay.portlet.social.model.impl." + "SocialActivitySetImpl", PortalClassLoaderUtil.getClassLoader())); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); qPos.add(StringUtil.merge(types)); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { try { throw new SystemException(e); } catch (SystemException se) { se.printStackTrace(); } } finally { closeSession(session); } return 0; }
From source file:com.liferay.social.activity.customizer.service.persistence.impl.CustomSocialActivitySetFinderImpl.java
License:Open Source License
public List<SocialActivitySet> findByU_C(long userId, long classNameId, int begin, int end) { Session session = null;/*www . j a v a 2 s. c o m*/ try { session = CustomFinderHelperUtil.openPortalSession(); String sql = CustomSQLUtil.get(CustomSocialActivitySetFinderImpl.class, FIND_BY_USERID_CLASSNAMEID); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setCacheable(false); q.addEntity("SocialActivitySet", CustomFinderHelperUtil.getImplClass( "com.liferay.portlet.social.model.impl." + "SocialActivitySetImpl", PortalClassLoaderUtil.getClassLoader())); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); return (List<SocialActivitySet>) QueryUtil.list(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); } catch (Exception e) { try { throw new SystemException(e); } catch (SystemException se) { se.printStackTrace(); } } finally { closeSession(session); } return null; }
From source file:com.liferay.social.activity.customizer.service.persistence.impl.CustomSocialActivitySetFinderImpl.java
License:Open Source License
public List<SocialActivitySet> findByU_C_T(long userId, long classNameId, long[] types, int begin, int end) { Session session = null;//from w ww .j a va2 s . c o m try { session = CustomFinderHelperUtil.openPortalSession(); String sql = CustomSQLUtil.get(CustomSocialActivitySetFinderImpl.class, FIND_BY_USERID_CLASSNAMEID_TYPE); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setCacheable(false); q.addEntity("SocialActivitySet", CustomFinderHelperUtil.getImplClass( "com.liferay.portlet.social.model.impl." + "SocialActivitySetImpl", PortalClassLoaderUtil.getClassLoader())); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); qPos.add(StringUtil.merge(types)); return (List<SocialActivitySet>) QueryUtil.list(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); } catch (Exception e) { try { throw new SystemException(e); } catch (SystemException se) { se.printStackTrace(); } } finally { closeSession(session); } return null; }
From source file:org.oep.cmon.dao.cc.service.persistence.ChucVuFinderImpl.java
License:Apache License
/** * This is fucntion find ChucVu by coQuanQuanLyId and TrangThai * Version: 1.0/*w w w . j a va2 s .c om*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long : Value of coQuanQuanLyId; long : Value of trangThai * @return List<ChucVu> */ @SuppressWarnings("unchecked") public List<ChucVu> findByCoQuanQuanLy(long coQuanQuanLyId, long daXoa) { Session session = null; List<ChucVu> listChucVu = new ArrayList<ChucVu>(); try { session = openSession(); StringBuffer sql = new StringBuffer(); sql.append( "SELECT a.* FROM cmon_chucvu a INNER JOIN (SELECT distinct chucvuid FROM cmon_chucvu2vaitro WHERE coquanquanlyid = :coquanquanlyid) b ON a.id = b.chucvuid"); sql.append(" AND a.daxoa=:daxoa"); sql.append(" ORDER BY a.ten ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.setCacheable(false); q.setLong("coquanquanlyid", coQuanQuanLyId); q.setLong("daxoa", daXoa); q.addEntity("ChucVu", ChucVuImpl.class); listChucVu = (List<ChucVu>) q.list(); if (listChucVu == null) { listChucVu = new ArrayList<ChucVu>(); } } catch (Exception e) { } finally { closeSession(session); } return listChucVu; }
From source file:org.oep.cmon.dao.cc.service.persistence.CongChucFinderImpl.java
License:Apache License
/** * This is fucntion find CongChuc by coQuanQuanLyId and start, end value for paging * Version: 1.0//w w w . j av a 2 s.c o m * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long : Value of coQuanQuanLyId; int start ; int end; * @return List<CongChuc> */ @SuppressWarnings("unchecked") public List<CongChuc> listCanBoTiepNhan(long coQuanQuanLyId, int start, int end) { Session session = null; try { session = openSession(); // now we build the query. Note that we use the name of the tables // from the database! String sql = "SELECT * FROM CMON_CONGCHUC T1 , CMON_CHUCVU T2 WHERE T1.CHUCVUID = T2.ID AND T1.COQUANQUANLYID = " + coQuanQuanLyId + " AND " + "T2.MA =(SELECT GIATRI FROM CMON_THAMSO WHERE TEN ='CHUCVU_MOTCUA') AND T1.DAXOA=0 AND T2.DAXOA=0"; // Now that we have built the query, we can do all the usual stuff. SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("CongChuc", CongChucImpl.class); // execute the query and return a list from the db return (List<CongChuc>) QueryUtil.list(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); } catch (Exception e) { } finally { closeSession(session); } return new ArrayList<CongChuc>(); }
From source file:org.oep.cmon.dao.cc.service.persistence.CongChucFinderImpl.java
License:Apache License
/** * This is fucntion find CongChuc by coQuanQuanLyId and keyword and start, end value for paging * Version: 1.0/*from ww w. j a v a2s . co m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long : Value of coQuanQuanLyId; string keyword; int start ; int end; * @return List<CongChuc> */ @SuppressWarnings("unchecked") public List<CongChuc> listCongChuc(long coQuanQuanLyId, String maOrTenOrEmail, int start, int end) throws SystemException { List<CongChuc> listCongChuc = new ArrayList<CongChuc>(); Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(); sql.append( "SELECT a.* FROM cmon_congchuc a INNER JOIN cmon_taikhoannguoidung b ON a.taikhoannguoidungid = b.id WHERE 1=1"); if (!Helpers.isEmpty(maOrTenOrEmail)) { sql.append( " AND (upper(a.ma) LIKE (:maOrTenOrEmail) OR upper(a.hovaten) LIKE (:maOrTenOrEmail) OR upper(b.email) LIKE(:maOrTenOrEmail))"); } if (coQuanQuanLyId > 0) { sql.append(" AND a.coquanquanlyid = :coquanquanlyid"); } sql.append(" ORDER BY a.hovaten ASC"); SQLQuery q = session.createSQLQuery(sql.toString()); q.setCacheable(false); q.setLong("coquanquanlyid", coQuanQuanLyId); q.setString("maOrTenOrEmail", StringPool.PERCENT + maOrTenOrEmail.toUpperCase() + StringPool.PERCENT); q.addEntity("CongChuc", CongChucImpl.class); listCongChuc = (List<CongChuc>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { } finally { closeSession(session); } return listCongChuc; }
From source file:org.oep.cmon.dao.cc.service.persistence.CongChucFinderImpl.java
License:Apache License
/** * This is fucntion count CongChuc by coQuanQuanLyId and keyword * Version: 1.0/*from w w w . j a va2 s.c o m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long : Value of coQuanQuanLyId; string keyword; * @return int */ public int countListCongChuc(long coQuanQuanLyId, String maOrTenOrEmail) throws SystemException { int total = 0; Session session = null; try { session = openSession(); StringBuffer sql = new StringBuffer(); sql.append( "SELECT count(a.id) FROM cmon_congchuc a INNER JOIN cmon_taikhoannguoidung b ON a.taikhoannguoidungid = b.id WHERE 1=1"); if (!Helpers.isEmpty(maOrTenOrEmail)) { sql.append( " AND (upper(a.ma) LIKE (:maOrTenOrEmail) OR upper(a.hovaten) LIKE (:maOrTenOrEmail) OR upper(b.email) LIKE(:maOrTenOrEmail))"); } if (coQuanQuanLyId > 0) { sql.append(" AND a.coquanquanlyid = :coquanquanlyid"); } SQLQuery q = session.createSQLQuery(sql.toString()); q.setCacheable(false); q.setLong("coquanquanlyid", coQuanQuanLyId); q.setString("maOrTenOrEmail", StringPool.PERCENT + maOrTenOrEmail.toUpperCase() + StringPool.PERCENT); total = Integer.valueOf(q.uniqueResult().toString()); } catch (Exception e) { } finally { closeSession(session); } return total; }
From source file:org.oep.cmon.dao.cd.service.persistence.ChuyenMonFinderImpl.java
License:Apache License
/** * This is fucntion get ChuyenMon by MaDanhMucUngDung * Version: 1.0/*from w ww . j ava2 s . c om*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param String maDanhMucUngDung * @return List<ChuyenMon> */ public List<ChuyenMon> getDanhSachChuyenMonByMaDanhMucUngDung(String maDanhMucUngDung) { List<ChuyenMon> result = null; Session session = null; try { session = openSession(); // Here ends the basic set up; // now we build the query. Note that we use the name of the tables // from the database! String base = "SELECT * FROM CMON_CHUYENMON "; StringBuffer sqlBuilder = new StringBuffer(base); sqlBuilder.append("INNER JOIN CMON_DANHMUCUNGDUNG "); sqlBuilder.append("ON CMON_CHUYENMON.DANHMUCUNGDUNGID = CMON_DANHMUCUNGDUNG.ID "); sqlBuilder.append("WHERE CMON_DANHMUCUNGDUNG.MA = '" + maDanhMucUngDung); sqlBuilder.append("'"); String sql = sqlBuilder.toString(); // Now that we have built the query, we can do all the usual stuff. SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("ChuyenMon", ChuyenMonImpl.class); QueryPos.getInstance(q); // execute the query and return a list from the db int start = 0; int end = 100; result = (List<ChuyenMon>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { e.printStackTrace(); } 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 result; }
From source file:org.oep.cmon.dao.dn.service.persistence.DoanhNghiepFinderImpl.java
License:Apache License
/** * This is fucntion find DoanhNghiep by nguoiDaiDienId * Version: 1.0/*from w w w . j av a2s .co m*/ * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 3-March-2013 Nam Dinh Create new * @param long nguoiDaiDienId * @return List<DoanhNghiep> */ public java.util.List<DoanhNghiep> getDoanhNghiep2NguoiDaiDienId(long nguoiDaiDienId) { java.util.List<DoanhNghiep> result = null; Session session = null; try { session = openSession(); // Here ends the basic set up; // now we build the query. Note that we use the name of the tables // from the database! String base = " SELECT * FROM BRMS_DOANHNGHIEP "; StringBuffer sqlBuilder = new StringBuffer(base); sqlBuilder.append(" WHERE NGUOIDAIDIENID = "); sqlBuilder.append(nguoiDaiDienId); String sql = sqlBuilder.toString(); // Now that we have built the query, we can do all the usual stuff. SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("DoanhNghiep", DoanhNghiepImpl.class); QueryPos qPos = QueryPos.getInstance(q); // execute the query and return a list from the db result = (List<DoanhNghiep>) QueryUtil.list(q, getDialect(), 0, 100); } catch (Exception e) { e.printStackTrace(); } 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 result; }