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


Java Restrictions.ge方法代码示例

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


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

示例1: count

import org.hibernate.criterion.Restrictions; //导入方法依赖的package包/类
@SuppressWarnings("nls")
@Override
public long count(String freetext, Date[] dates, String userId, Institution institution)
{
	Criterion dateRestriction = null;
	if( dates != null )
	{
		Date start = dates[0];
		Date end = dates[1];

		if( start != null && end != null ) // BETWEEN and ON
		{
			dateRestriction = Restrictions.between("dateModified", start, end);
		}
		else if( start != null && end == null ) // AFTER
		{
			dateRestriction = Restrictions.ge("dateModified", start);
		}
		else if( start == null && end != null ) // BEFORE
		{
			dateRestriction = Restrictions.le("dateModified", end);
		}
	}
	if( dateRestriction != null )
	{
		return countByCriteria(Restrictions.eq("owner", userId), Restrictions.eq("institution", institution),
			dateRestriction, Restrictions.ilike("name", "%" + freetext + "%"));
	}
	else
	{
		return countByCriteria(Restrictions.eq("owner", userId), Restrictions.eq("institution", institution),
			Restrictions.ilike("name", "%" + freetext + "%"));
	}

}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:FavouriteSearchDaoImpl.java

示例2: buildCriterion

import org.hibernate.criterion.Restrictions; //导入方法依赖的package包/类
/**
 * 按属性条件参数创建Criterion,辅助函数.
 */
protected Criterion buildCriterion(final String propertyName, final Object propertyValue, final MatchType matchType) {
	AssertUtils.hasText(propertyName, "propertyName不能为空");
	Criterion criterion = null;
	//根据MatchType构造criterion
	switch (matchType) {
	case EQ:
		criterion = Restrictions.eq(propertyName, propertyValue);
		break;
	case LIKE:
		criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
		break;

	case LE:
		criterion = Restrictions.le(propertyName, propertyValue);
		break;
	case LT:
		criterion = Restrictions.lt(propertyName, propertyValue);
		break;
	case GE:
		criterion = Restrictions.ge(propertyName, propertyValue);
		break;
	case GT:
		criterion = Restrictions.gt(propertyName, propertyValue);
		break;
	case NE:
		criterion = Restrictions.ne(propertyName, propertyValue);
	}
	return criterion;
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:33,代码来源:HibernateDao.java

示例3: restricions

import org.hibernate.criterion.Restrictions; //导入方法依赖的package包/类
@Override
public void restricions() {
	Session ses=null;
	//get the session
	ses=HibernateUtil.getSession();
	
		System.out.println("\n\tPRICE Less than 500");
		//create criteria
	Criteria c=ses.createCriteria(product.class);
	//create criterion objects for the restriction methods
	Criterion lt=Restrictions.lt("price", 500f);
	//add restriction to criteria
	c.add(lt);
	//execute the Criteria
	List<product> list=c.list();
	//display the list
		list.forEach(row->{
			System.out.println(row);
		});
		
	System.out.println("\n\tPRICE Greater than 500");
	
	Criteria c1=ses.createCriteria(product.class);
	
	Criterion gt=Restrictions.gt("price", 500f);
	c1.add(gt);
	List<product> list1=c1.list();
		list1.forEach(row->{
			System.out.println(row);
		});
		
System.out.println("\n\tPRICE Less than or Equal 500");
		Criteria c2=ses.createCriteria(product.class);
		
		Criterion le=Restrictions.le("price", 500f);
		c2.add(le);
		List<product> list2=c2.list();
			list2.forEach(row->{
				System.out.println(row);
			});
			
			System.out.println("\n\tPRICE Greater than or Equal 500");
					Criteria c3=ses.createCriteria(product.class);
					
					Criterion ge=Restrictions.ge("price", 500f);
					c3.add(ge);
					List<product> list3=c3.list();
						list3.forEach(row->{
							System.out.println(row);
						});
						
						
								Criteria c4=ses.createCriteria(product.class);
								
								Criterion eq=Restrictions.eq("price", 500f);
								c4.add(eq);
								List<product> list4=c4.list();
								System.out.println("\n\tPRICE  Equal 500");
									list4.forEach(row->{
										System.out.println(row);
									});
									//close the session
									HibernateUtil.closeSession(ses);
}
 
开发者ID:pratikdimble,项目名称:Hibernate_Criteria_Queries_Using_DAO_Using_MAVEN,代码行数:65,代码来源:DAO_IMPL.java

示例4: buildCriterion

import org.hibernate.criterion.Restrictions; //导入方法依赖的package包/类
/**
 * 按属性条件参数创建Criterion,辅助函数.
 * 
 * @param propertyName
 *            String
 * @param propertyValue
 *            Object
 * @param matchType
 *            MatchType
 * @return Criterion
 */
public static Criterion buildCriterion(String propertyName,
        Object propertyValue, MatchType matchType) {
    Assert.hasText(propertyName, "propertyName不能为空");

    Criterion criterion = null;

    // 根据MatchType构造criterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);

        break;

    case NOT:
        criterion = Restrictions.ne(propertyName, propertyValue);

        break;

    case LIKE:
        criterion = Restrictions.like(propertyName, (String) propertyValue,
                MatchMode.ANYWHERE);

        break;

    case LE:
        criterion = Restrictions.le(propertyName, propertyValue);

        break;

    case LT:
        criterion = Restrictions.lt(propertyName, propertyValue);

        break;

    case GE:
        criterion = Restrictions.ge(propertyName, propertyValue);

        break;

    case GT:
        criterion = Restrictions.gt(propertyName, propertyValue);

        break;

    case IN:
        criterion = Restrictions.in(propertyName,
                (Collection) propertyValue);

        break;

    case INL:
        criterion = Restrictions.isNull(propertyName);

        break;

    case NNL:
        criterion = Restrictions.isNotNull(propertyName);

        break;

    default:
        criterion = Restrictions.eq(propertyName, propertyValue);

        break;
    }

    return criterion;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:80,代码来源:HibernateUtils.java


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