当前位置: 首页>>代码示例>>Java>>正文


Java DetachedCriteria类代码示例

本文整理汇总了Java中org.hibernate.criterion.DetachedCriteria的典型用法代码示例。如果您正苦于以下问题:Java DetachedCriteria类的具体用法?Java DetachedCriteria怎么用?Java DetachedCriteria使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DetachedCriteria类属于org.hibernate.criterion包,在下文中一共展示了DetachedCriteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareItemQuery

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
@Override
public void prepareItemQuery(ItemSerializerState state)
{
	final DetachedCriteria criteria = state.getItemQuery();
	final ProjectionList projection = state.getItemProjection();

	if( state.hasCategory(ItemSerializerService.CATEGORY_BASIC) )
	{
		projection.add(Projections.property("name.id"), NAME_ALIAS);
		projection.add(Projections.property("description.id"), DESC_ALIAS);
	}

	if( state.hasCategory(ItemSerializerService.CATEGORY_METADATA) )
	{
		criteria.createAlias("itemXml", "itemXml");
		projection.add(Projections.property("itemXml.xml"), METADATA_ALIAS);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:BasicItemSerializerProvider.java

示例2: 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

示例3: findByCriteria

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
@Override
public List<?> findByCriteria(final DetachedCriteria criteria, final int firstResult, final int maxResults)
		throws DataAccessException {

	Assert.notNull(criteria, "DetachedCriteria must not be null");
	return executeWithNativeSession(new HibernateCallback<List<?>>() {
		@Override
		@SuppressWarnings("unchecked")
		public List<?> doInHibernate(Session session) throws HibernateException {
			Criteria executableCriteria = criteria.getExecutableCriteria(session);
			prepareCriteria(executableCriteria);
			if (firstResult >= 0) {
				executableCriteria.setFirstResult(firstResult);
			}
			if (maxResults > 0) {
				executableCriteria.setMaxResults(maxResults);
			}
			return executableCriteria.list();
		}
	});
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HibernateTemplate.java

示例4: 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

示例5: createFlowsCriteria

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private static DetachedCriteria createFlowsCriteria(FlowFinderCriteria finderCriteria) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Flow.class)
            .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
            .setFetchMode("parts", FetchMode.JOIN) // eager
            .add(ge("creationTime", finderCriteria.getFrom()))
            .addOrder(Order.desc("identifier"));

    if (finderCriteria.getApplication() != null) {
        // constrain query to a certain application name
        criteria.add(eq("application", finderCriteria
                .getApplication()));
    }
    if (finderCriteria.getTo() != null) {
        // there's an upper limit to creationTime property
        criteria.add(Restrictions
                .le("creationTime", finderCriteria.getTo()));
    }

    return criteria;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:21,代码来源:FlowRepositoryImpl.java

示例6: createPurgeCriteria

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private static DetachedCriteria createPurgeCriteria(FlowPurgeCriteria purgeCriteria) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Flow.class)
        .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
        // purge all flows with a creation time older than time limit
        .add(lt("creationTime", purgeCriteria.getTimeLimit()))
        // purge oldest flows first
        .addOrder(Order.asc("creationTime"));

    if (purgeCriteria.getApplication() != null) {
        criteria.add(eq("application", purgeCriteria.getApplication()));
    }
    
    if (purgeCriteria.getPurgeMode() == PurgeMode.CLEAN) {
        // omit flows with error status
        criteria.add(
            or(
                eq("derivedStatus", FlowStatus.CLEAN),
                isNull("derivedStatus") // old flows (both CLEAN and ERROR)
            ) 
        );
        
    }
    return criteria;
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:25,代码来源:FlowRepositoryImpl.java

示例7: getLast

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
@Override
public QuotePE getLast(String sigle) {
	Session session = getSession();

	DetachedCriteria  maxDate = DetachedCriteria.forClass(QuotePE.class);
	maxDate.add(Restrictions.eq("symbol", sigle));
	maxDate.setProjection(Projections.max("creationDateTime"));
	
   	Criteria criteria = session.createCriteria(QuotePE.class);
   	criteria.add(Restrictions.eq("symbol", sigle));
   	criteria.add(Property.forName("creationDateTime").eq(maxDate));
   	
	QuotePE pe = (QuotePE) criteria.uniqueResult();
	session.close();
	
	return pe;
}
 
开发者ID:auTasso,项目名称:SandBoxNGSB,代码行数:18,代码来源:QuoteDAOImpl.java

示例8: process

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
@Override
public RpcGetAuthorizCustomer process(CmdParams cmdParams, String ipAdress, byte[] IP) {
    QLog.l().logQUser().debug("getClientAuthorization");
    super.process(cmdParams, ipAdress, IP);
    // Вытащим из базы предварительного кастомера
    if (cmdParams.clientAuthId == null || cmdParams.clientAuthId.isEmpty()) {
        return new RpcGetAuthorizCustomer(null);
    }
    final List<QAuthorizationCustomer> authCusts = Spring.getInstance().getHt()
        .findByCriteria(
            DetachedCriteria.forClass(QAuthorizationCustomer.class)
                .add(Restrictions.eq("authId", cmdParams.clientAuthId).ignoreCase()));
    final QAuthorizationCustomer authCust;
    if (authCusts.isEmpty() || authCusts.get(0) == null || authCusts.get(0).getId() == null
        || authCusts.get(0).getName() == null) {
        QLog.l().logger()
            .trace("Не найден клиент по его ID = '" + cmdParams.clientAuthId + "'");
        authCust = null;
    } else {
        authCust = authCusts.get(0);
    }
    return new RpcGetAuthorizCustomer(authCust);
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:24,代码来源:Executer.java

示例9: 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

示例10: loadMessageTemplates

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
public void loadMessageTemplates(Page<MessageTemplate> page,Criteria criteria,String type){
	IUser user=ContextHolder.getLoginUser();
	if(user==null){
		throw new RuntimeException("Please login first!");
	}
	String companyId=user.getCompanyId();
	if(StringUtils.isNotEmpty(getFixedCompanyId())){
		companyId=getFixedCompanyId();
	}
	DetachedCriteria dc=this.buildDetachedCriteria(criteria, MessageTemplate.class);
	if(StringUtils.isNotEmpty(type)){
		dc.add(Property.forName("type").eq(type));
	}
	Property p=Property.forName("companyId");
	dc.add(p.eq(companyId));
	this.pagingQuery(page, dc);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:18,代码来源:MessageTemplateServiceImpl.java

示例11: createEcrfFieldValueDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private static DetachedCriteria createEcrfFieldValueDetachedCriteria(org.hibernate.Criteria ecrfFieldValueCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = DetachedCriteria.forClass(ECRFFieldValueImpl.class, "ecrfFieldValue1"); // IMPL!!!!
	// subQuery.setProjection(Projections.max("id"));
	if (probandListEntryId == null) {
		if (probandListEntryCriteria == null) {
			probandListEntryCriteria = ecrfFieldValueCriteria.createCriteria("listEntry", "probandListEntry0");
		}
		subQuery.add(Restrictions.eqProperty("listEntry.id", probandListEntryCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
	}
	if (ecrfFieldId == null) {
		if (ecrfFieldCriteria == null) {
			ecrfFieldCriteria = ecrfFieldValueCriteria.createCriteria("ecrfField", "ecrfField0");
		}
		subQuery.add(Restrictions.eqProperty("ecrfField.id", ecrfFieldCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("ecrfField.id", ecrfFieldId.longValue()));
	}
	return subQuery;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:24,代码来源:ECRFFieldValueDaoImpl.java

示例12: buildCriterions

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private void buildCriterions(Collection<com.bstek.dorado.data.provider.Criterion> criterions, DetachedCriteria dc) {
	for (com.bstek.dorado.data.provider.Criterion c : criterions) {
		if (c instanceof SingleValueFilterCriterion) {
			SingleValueFilterCriterion fc = (SingleValueFilterCriterion) c;
			dc.add(this.buildCriterion(fc));
		}
		if (c instanceof Junction) {
			Junction jun = (Junction) c;
			org.hibernate.criterion.Junction junction = null;
			if (jun instanceof Or) {
				junction = Restrictions.disjunction();
			} else if (jun instanceof And) {
				junction = Restrictions.conjunction();
			}
			Collection<com.bstek.dorado.data.provider.Criterion> subCriterions = jun.getCriterions();
			if (subCriterions != null) {
				buildCriterions(subCriterions, junction);
			}
			dc.add(junction);
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:HibernateDao.java

示例13: createEcrfFieldStatusEntryDetachedCriteria

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private static DetachedCriteria createEcrfFieldStatusEntryDetachedCriteria(org.hibernate.Criteria ecrfFieldStatusEntryCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = DetachedCriteria.forClass(ECRFFieldStatusEntryImpl.class, "ecrfFieldStatusEntry1"); // IMPL!!!!
	// subQuery.setProjection(Projections.max("id"));
	if (probandListEntryId == null) {
		if (probandListEntryCriteria == null) {
			probandListEntryCriteria = ecrfFieldStatusEntryCriteria.createCriteria("listEntry", "probandListEntry0");
		}
		subQuery.add(Restrictions.eqProperty("listEntry.id", probandListEntryCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
	}
	if (ecrfFieldId == null) {
		if (ecrfFieldCriteria == null) {
			ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0");
		}
		subQuery.add(Restrictions.eqProperty("ecrfField.id", ecrfFieldCriteria.getAlias() + ".id"));
	} else {
		subQuery.add(Restrictions.eq("ecrfField.id", ecrfFieldId.longValue()));
	}
	return subQuery;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:24,代码来源:ECRFFieldStatusEntryDaoImpl.java

示例14: createEcrfFieldStatusEntryDetachedCriteriaMaxId

import org.hibernate.criterion.DetachedCriteria; //导入依赖的package包/类
private static DetachedCriteria createEcrfFieldStatusEntryDetachedCriteriaMaxId(org.hibernate.Criteria ecrfFieldStatusEntryCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		ECRFFieldStatusQueue queue, Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = createEcrfFieldStatusEntryDetachedCriteria(ecrfFieldStatusEntryCriteria, ecrfFieldCriteria, probandListEntryCriteria, probandListEntryId,
			ecrfFieldId);
	if (queue != null) {
		subQuery.add(Restrictions.eq("queue", queue));
		subQuery.setProjection(Projections.max("id"));
	} else {
		ProjectionList proj = Projections.projectionList();
		proj.add(Projections.sqlGroupProjection(
				"max({alias}.id) as maxId",
				"{alias}.queue",
				new String[] { "maxId" },
				new org.hibernate.type.Type[] { Hibernate.LONG }));
		subQuery.setProjection(proj);
	}

	return subQuery;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:21,代码来源:ECRFFieldStatusEntryDaoImpl.java

示例15: 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


注:本文中的org.hibernate.criterion.DetachedCriteria类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。