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


Java DetachedCriteria.add方法代码示例

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


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

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

示例2: getNoCollectionProducts

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
/**
 * Returns all products not contained in a collection.
 * @return a set of products.
 */
@Transactional(readOnly = true)
public Set<Product> getNoCollectionProducts ()
{
   DetachedCriteria criteria = DetachedCriteria.forClass (Product.class);
   Iterator<Product> it =
         collectionService.getAllProductInCollection ().iterator ();

   HashSet<Long> cpid = new HashSet<> ();
   while (it.hasNext ())
   {
      cpid.add (it.next ().getId ());
   }

   if (!cpid.isEmpty())
   {
      criteria.add(Restrictions.not(Restrictions.in("id", cpid)));
   }
   criteria.add (Restrictions.eq ("processed", true));
   return new HashSet<> (productDao.listCriteria (criteria, 0, -1));
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:25,代码来源:ProductService.java

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

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

示例5: getProductByOrigin

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@Transactional(readOnly = true)
public Product getProductByOrigin (final String origin)
{
   DetachedCriteria criteria = DetachedCriteria.forClass (Product.class);
   criteria.add (Restrictions.eq ("origin", origin));
   return productDao.uniqueResult (criteria);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:8,代码来源:ProductService.java

示例6: loadAssignmentDefs

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@DataProvider
public void loadAssignmentDefs(Page<AssignmentDef> page,Criteria criteria){
	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, AssignmentDef.class);
	Property p=Property.forName("companyId");
	dc.add(p.eq(companyId));
	this.pagingQuery(page, dc);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:16,代码来源:NodeConfig.java

示例7: getProductsByCreationDate

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
/**
 * Retrieve products ordered by it date of ingestion, updated.
 * The list of product is returned prior to the passed date argument.
 * Currently processed and locked products are not returned.
 *
 * @param max_date     Maximum date to retrieve products
 *                     More recent product will not be returned
 * @param max_products Maximum products to return
 * @return a scrollable list of the products
 */
@Transactional(readOnly = true)
public Iterator<Product> getProductsByCreationDate(Date max_date, int max_products)
{
   DetachedCriteria criteria = DetachedCriteria.forClass(Product.class);
   criteria.add(Restrictions.and(
         Restrictions.lt("created", max_date),
         Restrictions.and(
               Restrictions.eq("processed", true),
               Restrictions.eq("locked", false))));
   criteria.addOrder(Order.asc("created"));

   return productDao.listCriteria(criteria, 0, max_products).iterator();
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:24,代码来源:ProductService.java

示例8: getJobDefinition

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
public JobDefinition getJobDefinition(String jobDefId) {
	DetachedCriteria dc = DetachedCriteria.forClass(JobDefinition.class, "m");
	dc.add(Restrictions.eq("id", jobDefId));
	@SuppressWarnings("unchecked")
	Collection<JobDefinition> list = (Collection<JobDefinition>) this.query(dc);
	if (list.isEmpty()) {
		return null;
	} else {
		return list.iterator().next();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:12,代码来源:JobDefinitionServiceImpl.java

示例9: loadJobCalendars

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@DataProvider
public void loadJobCalendars(Page<JobCalendar> page,Criteria criteria){
	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, JobCalendar.class);
	Property p=Property.forName("companyId");
	dc.add(p.eq(companyId));
	this.pagingQuery(page, dc);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:16,代码来源:NodeConfig.java

示例10: addWhere

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@Override
public void addWhere(ItemSerializerState state)
{
	ProjectionList projections = state.getItemProjection();
	DetachedCriteria criteria = state.getItemQuery();
	criteria.add(Restrictions.eq("uuid", uuid));
	criteria.addOrder(Order.asc(PROPERTY_VERSION));
	projections.add(Projections.property(PROPERTY_VERSION), ALIAS_VERSION);
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:AllVersionsWhereClause.java

示例11: addWhere

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@Override
public void addWhere(ItemSerializerState state)
{
	DetachedCriteria criteria = state.getItemQuery();
	ProjectionList projections = state.getItemProjection();
	criteria.add(Restrictions.eq("uuid", uuid));
	if( live )
	{
		criteria.add(Restrictions.eq("status", ItemStatus.LIVE.name()));
	}
	criteria.addOrder(Order.desc(PROPERTY_VERSION));
	projections.add(Projections.property(PROPERTY_VERSION), ALIAS_VERSION);
	state.setMaxResults(1);
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:LatestVersionWhereClause.java

示例12: loadComponentConfigsByViewName

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<ComponentConfig> loadComponentConfigsByViewName(String viewName) {
	DetachedCriteria dc = DetachedCriteria.forClass(ComponentConfig.class);
	dc.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
	dc.add(Restrictions.like("controlId", viewName + ".%"));
	dc.createAlias("componentConfigMembers", "m", CriteriaSpecification.LEFT_JOIN);
	dc.addOrder(Order.asc("m.order"));
	return (List<ComponentConfig>) this.query(dc);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:HibernateComponentConfigManager.java

示例13: applyEcrfFieldValueMaxIdSubCriteria

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
private static void applyEcrfFieldValueMaxIdSubCriteria(org.hibernate.Criteria ecrfFieldValueCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = createEcrfFieldValueDetachedCriteriaMaxId(ecrfFieldValueCriteria, ecrfFieldCriteria, probandListEntryCriteria, probandListEntryId, ecrfFieldId);
	subQuery.add(Restrictions.or(Restrictions.isNull("index"),
			Restrictions.eqProperty("index", ecrfFieldValueCriteria.getAlias() + ".index")));
	ecrfFieldValueCriteria.add(Subqueries.propertyEq("id", subQuery));
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:ECRFFieldValueDaoImpl.java

示例14: checkFreeDay

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
/**
 * Проверка даты на нерабочую в определенном календаре
 *
 * @param date проверяемая дата, важен месяц и день
 * @return Выходной день в этом календаре или нет
 */
public boolean checkFreeDay(Date date) {
    final DetachedCriteria criteria = DetachedCriteria.forClass(FreeDay.class);
    criteria.add(Property.forName("calendarId").eq(getId()));
    criteria.add(Property.forName("date").eq(date));
    return !(new LinkedList<>(Spring.getInstance().getHt().findByCriteria(criteria)).isEmpty());
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:13,代码来源:QCalendar.java

示例15: handleFindExpiring

import org.hibernate.criterion.DetachedCriteria; //导入方法依赖的package包/类
@Override
protected Collection<Password> handleFindExpiring(Date today,
		Long departmentId, AuthenticationType authMethod, VariablePeriod reminderPeriod,
		Long reminderPeriodDays, PSFVO psf) throws Exception {
	org.hibernate.Criteria passwordCriteria = createPasswordCriteria("password0");
	SubCriteriaMap criteriaMap = new SubCriteriaMap(Password.class, passwordCriteria);
	if (departmentId != null) {
		criteriaMap.createCriteria("user").add(Restrictions.eq("department.id", departmentId.longValue()));
	}
	if (authMethod != null) {
		criteriaMap.createCriteria("user").add(Restrictions.eq("authMethod", authMethod));
	}
	DetachedCriteria subQuery = DetachedCriteria.forClass(PasswordImpl.class, "password1"); // IMPL!!!!
	subQuery.add(Restrictions.eqProperty("password1.user", "password0.user"));
	subQuery.setProjection(Projections.max("id"));
	passwordCriteria.add(Subqueries.propertyEq("id", subQuery));
	passwordCriteria.add(Restrictions.eq("expires", true)); // performance only...
	if (psf != null) {
		PSFVO sorterFilter = new PSFVO();
		sorterFilter.setFilters(psf.getFilters());
		sorterFilter.setSortField(psf.getSortField());
		sorterFilter.setSortOrder(psf.getSortOrder());
		CriteriaUtil.applyPSFVO(criteriaMap, sorterFilter);
	}
	ArrayList<Password> resultSet = CriteriaUtil.listExpirations(passwordCriteria, today, null, null, null, reminderPeriod, reminderPeriodDays);
	return (Collection<Password>) CriteriaUtil.applyPVO(resultSet, psf, false); // no dupes by default
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:28,代码来源:PasswordDaoImpl.java


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