當前位置: 首頁>>代碼示例>>Java>>正文


Java DetachedCriteria.getExecutableCriteria方法代碼示例

本文整理匯總了Java中org.hibernate.criterion.DetachedCriteria.getExecutableCriteria方法的典型用法代碼示例。如果您正苦於以下問題:Java DetachedCriteria.getExecutableCriteria方法的具體用法?Java DetachedCriteria.getExecutableCriteria怎麽用?Java DetachedCriteria.getExecutableCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.criterion.DetachedCriteria的用法示例。


在下文中一共展示了DetachedCriteria.getExecutableCriteria方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: listCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings ("unchecked")
public List<T> listCriteria (DetachedCriteria detached, int skip, int top)
{
   SessionFactory factory = getSessionFactory ();
   org.hibernate.classic.Session session = factory.getCurrentSession ();

   Criteria criteria = detached.getExecutableCriteria (session);

   if (skip > 0)
      criteria.setFirstResult (skip);
   if (top > 0)
      criteria.setMaxResults (top);
   return criteria.list ();
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:15,代碼來源:HibernateDao.java

示例2: execute

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
private Object execute(FlowFinderCriteria flowFinderCriteria,
        DetachedCriteria flowStatusCriteria, Session session,
        boolean idProjection) {

    Criteria criteria = flowStatusCriteria.getExecutableCriteria(session);

    if (idProjection) {
        criteria.setProjection(Projections.id());
    }
    
    int maxResults = flowFinderCriteria.getMaxResults();
    if (maxResults != FlowFinderCriteria.DEFAULT_MAX_RESULTS) {
        criteria.setMaxResults(maxResults);
    }

    if (flowFinderCriteria.hasMessageQuery()) {
        FlowSearchCriteria flowSearchCriteria = new FlowSearchCriteria();
        flowSearchCriteria.setHibernateCriteria(criteria);
        flowSearchCriteria.setInboundMessageQuery(flowFinderCriteria.getInboundMessageQuery());
        flowSearchCriteria.setOutboundMessageQuery(flowFinderCriteria.getOutboundMessageQuery());
        return flowSearchCallback.findFlows(session, flowSearchCriteria);
    } else {
        return criteria.list();
    }
}
 
開發者ID:oehf,項目名稱:ipf-flow-manager,代碼行數:26,代碼來源:FlowRepositoryImpl.java

示例3: deleteComponentProfileByControlId

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void deleteComponentProfileByControlId(String controlId, String name) {
	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ComponentConfig.class);
	detachedCriteria.add(Restrictions.eq("controlId", controlId));
	detachedCriteria.add(Restrictions.eq("name", name));
	Session session = this.getSessionFactory().openSession();
	try {
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		List<ComponentConfig> list = criteria.list();
		if (list.size() > 0) {
			String hql = "delete " + ComponentConfigMember.class.getName()
					+ " m where m.componentConfig.id = :configId";
			session.createQuery(hql).setString("configId", list.get(0).getId()).executeUpdate();
			session.delete(list.get(0));
		}
	} finally {
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:21,代碼來源:HibernateComponentConfigManager.java

示例4: uniqueResult

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings ("unchecked")
public T uniqueResult (DetachedCriteria criteria)
{
   Criteria excrit = criteria.getExecutableCriteria(getSessionFactory().getCurrentSession());
   excrit.setMaxResults(1);
   List<?> res = excrit.list();
   return res.isEmpty() ? null : (T) res.get(0);
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:9,代碼來源:HibernateDao.java

示例5: count

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
public int count (DetachedCriteria detached)
{
   Session session = getSessionFactory ().getCurrentSession ();
   Criteria criteria = detached.getExecutableCriteria (session);
   criteria.setProjection(Projections.rowCount());
   Object result = criteria.uniqueResult ();
   return ((Number) result).intValue ();
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:9,代碼來源:HibernateDao.java

示例6: findByCriteria

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public List findByCriteria(final DetachedCriteria detachedCriteria) throws Exception {
	Session session=this.getSessionFactory(dataSourceRegisterName).openSession();
	try{
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		return criteria.list();
	}finally{
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:12,代碼來源:ImportExcelHibernateDao.java

示例7: queryCount

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public int queryCount(DetachedCriteria detachedCriteria,String dataSourceName){
	Session session=this.getSessionFactory(dataSourceName).openSession();
	try{
		org.hibernate.Criteria criteria=detachedCriteria.getExecutableCriteria(session);
		try {
			Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
			field.setAccessible(true);
			field.set(criteria,new ArrayList());
		} catch (Exception e) {
			e.printStackTrace();
		}
		int totalCount=0;
		Object totalObject=criteria.setProjection(Projections.rowCount()).uniqueResult();
		if(totalObject instanceof Integer){
			totalCount=(Integer)totalObject;
		}else if(totalObject instanceof Long){
			totalCount=((Long)totalObject).intValue();			
		}else if (totalObject != null) {
			throw new RuntimeException("Can not convert ["+totalObject+"] to a int value when query entity total count!");
		}
		return totalCount;
	}finally{
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:28,代碼來源:HibernateDao.java

示例8: queryCount

import org.hibernate.criterion.DetachedCriteria; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public int queryCount(DetachedCriteria detachedCriteria, String dataSourceName) {
	Session session = this.getSessionFactory(dataSourceName).openSession();
	try {
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		try {
			Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
			field.setAccessible(true);
			field.set(criteria, new ArrayList());
		} catch (Exception e) {
			e.printStackTrace();
		}
		int totalCount = 0;
		Object totalObject = criteria.setProjection(Projections.rowCount()).uniqueResult();
		if (totalObject instanceof Integer) {
			totalCount = (Integer) totalObject;
		} else if (totalObject instanceof Long) {
			totalCount = ((Long) totalObject).intValue();
		} else if (totalObject != null) {
			throw new RuntimeException("Can not convert [" + totalObject
					+ "] to a int value when query entity total count!");
		}
		return totalCount;
	} finally {
		session.flush();
		session.close();
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:29,代碼來源:HibernateDao.java


注:本文中的org.hibernate.criterion.DetachedCriteria.getExecutableCriteria方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。