當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。