List of usage examples for org.hibernate.criterion Restrictions sqlRestriction
public static Criterion sqlRestriction(String sql)
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<StudyComp> searchStudyComp(StudyComp studyCompCriteria) { Criteria criteria = getSession().createCriteria(StudyComp.class); if (studyCompCriteria.getId() != null) { //criteria.add(Restrictions.like(Constants.ID, studyCompCriteria.getId().toString(),MatchMode.ANYWHERE)); //ARK-1558 criteria.add(Restrictions.sqlRestriction(" id LIKE '%" + studyCompCriteria.getId() + "%' ")); }//from w w w. j av a 2 s . c om if (studyCompCriteria.getName() != null) { criteria.add( Restrictions.ilike(Constants.STUDY_COMP_NAME, studyCompCriteria.getName(), MatchMode.ANYWHERE)); } if (studyCompCriteria.getKeyword() != null) { criteria.add(Restrictions.ilike(Constants.STUDY_COMP_KEYWORD, studyCompCriteria.getKeyword(), MatchMode.ANYWHERE)); } // Restrict the search for the study do not pull other study components criteria.add(Restrictions.eq("study", studyCompCriteria.getStudy())); List<StudyComp> list = criteria.list(); return list; }
From source file:cms.pageList.entity.ArchiverLabel.java
License:Apache License
public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName();// ?? if (tagLabel == null) return strTag; // ????ID/*from www . j ava 2 s . co m*/ List<Arctype> arctypeList = atm.getArctypeManager().getAdviceList(new Long(tagLabel.getTypeid())); String typeidStr = tagLabel.getTypeid() + ""; for (Arctype arctypeTest : arctypeList) { typeidStr += "," + arctypeTest.getId(); } // // ?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { String arcattStr = null;// for (Long flagid : tagLabel.getflagIds()) { arcattStr += "," + flagid; } // if (arcattStr != null) { // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "archives_id in ( select archives_id from archives_arcatt where arcatt_id in(" + arcattStr + ") )")); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")"), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "archives_id in ( select archives_id from archives_arcatt where arcatt_id in(" + arcattStr + ") )")); } } else { // // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0)); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } } } else { // ? // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } else { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0)); } } /*strTag = "<s:iterator value=\"pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>";*/ strTag = "<#list pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult() as xx >" + tagLabel.getBody() + "</#list>"; return strTag; }
From source file:cms.pageList.entity.GeneralArcPageLabel.java
License:Apache License
public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName(); // System.out.println("3:"+pageNo); //??? //from w ww .j a v a 2 s. c o m String typeidStr = pfValue("typeId", filters);//??ID typeidStr += arctypeidStr(new Long(Integer.parseInt(pfValue("typeId", filters))));//???ID // ?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } else {// ? System.out.println("B:" + typeidStr); addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } // ?? /*strTag = "<s:iterator value=\"pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>";*/ strTag = "<#list pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult() as xx >" + tagLabel.getBody() + "</#list>"; return strTag; }
From source file:cms.pageList.entity.GeneralShopPageLabel.java
License:Apache License
public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName(); // System.out.println("3:"+pageNo); // ????ID/*from w w w. java 2 s.co m*/ List<Arctype> arctypeList = sm.getArctypeManager() .getAdviceList(new Long(Integer.parseInt(pfValue("typeId", filters)))); String typeidStr = pfValue("typeId", filters); for (Arctype arctypeTest : arctypeList) { typeidStr += "," + arctypeTest.getId(); } //?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } else {//? addArchivesList(tagLabel.getRow(), Integer.parseInt(pfValue("pageNo", filters)), "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction("typeid in (" + typeidStr + ")")); } //?? /*strTag = "<s:iterator value=\"pagecontent.listLabel.get("+pfValue("getNum" ,filters)+").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>";*/ strTag = "<#list pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult() as xx >" + tagLabel.getBody() + "</#list>"; return strTag; }
From source file:cms.pageList.entity.SearcherLabel.java
License:Apache License
public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName();// ?? // System.out.println("------------------------------------"); if (tagLabel == null) return strTag; // /* w ww.ja v a2s . c o m*/ // ?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { String arcattStr = null;// for (Long flagid : tagLabel.getflagIds()) { arcattStr += "," + flagid; } // if (arcattStr != null) { // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "id in ( select archives_id from archives_arcatt where arcatt_id in(" + arcattStr + ") )"), Restrictions.or( Restrictions.like("title", pfValue("title", filters), MatchMode.ANYWHERE), Restrictions.like("body", pfValue("title", filters), MatchMode.ANYWHERE))); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.eq("typeid", tagLabel.getTypeid()), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "id in ( select archives_id from archives_arcatt where arcatt_id in(" + arcattStr + ") )"), Restrictions.or( Restrictions.like("title", pfValue("title", filters), MatchMode.ANYWHERE), Restrictions.like("body", pfValue("title", filters), MatchMode.ANYWHERE))); } } else { // // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.or( Restrictions.like("title", pfValue("title", filters), MatchMode.ANYWHERE), Restrictions.like("body", pfValue("title", filters), MatchMode.ANYWHERE))); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid()), Restrictions.or( Restrictions.like("title", pfValue("title", filters), MatchMode.ANYWHERE), Restrictions.like("body", pfValue("title", filters), MatchMode.ANYWHERE))); } } } else { // ? // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid())); } else { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0)); } } /*strTag = "<s:iterator value=\"pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>";*/ strTag = "<#list pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult() as xx >" + tagLabel.getBody() + "</#list>"; return strTag; }
From source file:cms.pageList.entity.ShopLabel.java
License:Apache License
public String getIterativeString(TagLabel tagLabel, List<PropertyFilter> filters) { String strTag = tagLabel.getTagName();// ?? if (tagLabel == null) return strTag; // // w ww. ja v a 2s . co m // ?? if ((!tagLabel.getOrderby().trim().equalsIgnoreCase("")) && (!tagLabel.getOrderbyType().trim().equalsIgnoreCase(""))) { String arcattStr = null;// for (Long flagid : tagLabel.getflagIds()) { arcattStr += "," + flagid; } // if (arcattStr != null) { // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "shop_id in ( select shop_id from shop_arcatt where arcatt_id in(" + arcattStr + ") )")); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.eq("typeid", tagLabel.getTypeid()), Restrictions.ge("arcrank", 0), Restrictions.sqlRestriction( "shop_id in ( select shop_id from shop_arcatt where arcatt_id in(" + arcattStr + ") )")); } } else { // // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0)); } else { addArchivesList(tagLabel.getRow(), 1, tagLabel.getOrderby(), tagLabel.getOrderbyType(), Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid())); } } } else { // ? // ?0,? if (tagLabel.getTypeid() == 0) { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0), Restrictions.eq("typeid", tagLabel.getTypeid())); } else { addArchivesList(tagLabel.getRow(), 1, "senddate", "desc", Restrictions.ge("arcrank", 0)); } } strTag = "<s:iterator value=\"pagecontent.listLabel.get(" + pfValue("getNum", filters) + ").getPage().getResult()\" status=\"st\">" + tagLabel.getBody() + "</s:iterator>"; return strTag; }
From source file:cn.trymore.core.dao.impl.DAOGenericImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<T> getAll(final boolean filter) throws DAOException { return (List<T>) getHibernateTemplate().execute(new HibernateCallback() { @Override/* ww w. jav a 2s. c o m*/ public Object doInHibernate(Session paramSession) throws HibernateException, SQLException { DetachedCriteria criteria = DetachedCriteria.forClass(DAOGenericImpl.this.entityClass); if (filter && UtilString.isNotEmpty(DAOGenericImpl.this.getQueryFilter())) { criteria.add(Restrictions.sqlRestriction(DAOGenericImpl.this.getQueryFilter())); DAOGenericImpl.this.setQueryFilter(null); } return getHibernateTemplate().findByCriteria(criteria); // String str = "from " + DAOGenericImpl.this.entityClass.getName(); //return paramSession.createQuery(str).list(); } }); }
From source file:cn.trymore.core.dao.impl.DAOGenericImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<T> getListByCriteria(final DetachedCriteria criteria, final boolean dataFilter) throws DAOException { if (dataFilter && UtilString.isNotEmpty(this.getQueryFilter())) { criteria.add(Restrictions.sqlRestriction(this.getQueryFilter())); this.setQueryFilter(null); }/*from w w w .j av a2 s. c o m*/ return (List<T>) getHibernateTemplate().findByCriteria(criteria); }
From source file:cn.trymore.core.dao.impl.DAOGenericImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<T> getListByCriteria(final DetachedCriteria criteria, int firstResult, int maxResults, final boolean dataFilter) throws DAOException { if (dataFilter && UtilString.isNotEmpty(this.getQueryFilter())) { criteria.add(Restrictions.sqlRestriction(this.getQueryFilter())); this.setQueryFilter(null); }//from www. j a v a2 s . c om return (List<T>) getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults); }
From source file:cn.trymore.core.dao.impl.DAOGenericImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public PaginationSupport<T> findPageByCriteria(final DetachedCriteria criteria, final int pageSize, final int startIndex, final boolean dataFilter) throws DAOException { if (dataFilter && UtilString.isNotEmpty(this.getQueryFilter())) { criteria.add(Restrictions.sqlRestriction(this.getQueryFilter())); this.setQueryFilter(null); }/*www.j av a2 s . c o m*/ return (PaginationSupport<T>) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Criteria execCriteria = criteria.getExecutableCriteria(session); int rowCount = ((Integer) execCriteria.setProjection(Projections.rowCount()).uniqueResult()) .intValue(); execCriteria.setProjection(null); execCriteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); //execCriteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY); execCriteria.setFirstResult(startIndex); if (pageSize > 0) { execCriteria.setMaxResults(pageSize); } else { execCriteria.setMaxResults(rowCount); } List<T> items = execCriteria.list(); return rowCount > 0 ? new PaginationSupport<T>(items, rowCount, startIndex, pageSize > 0 ? pageSize : rowCount) : null; } }); }