当前位置: 首页>>代码示例>>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;未经允许,请勿转载。