org.hibernate.criterion.Restrictions#like ( )源码实例Demo

下面列出了org.hibernate.criterion.Restrictions#like ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Knowage-Server   文件: CriteriaParameter.java
public Criterion toHibernateCriterion() {
	Criterion restriction = null;
	switch (getMatch()) {
	case LIKE:
		restriction = Restrictions.like(getName(), (String) getValue(), MatchMode.ANYWHERE);
		break;
	case ILIKE:
		restriction = Restrictions.like(getName(), (String) getValue(), MatchMode.ANYWHERE).ignoreCase();
		break;
	case NOT_EQ:
		restriction = Restrictions.ne(getName(), getValue());
		break;
	case IN:
		restriction = Restrictions.in(getName(), (Object[]) getValue());
		break;
	case NOT_IN:
		restriction = Restrictions.not(Restrictions.in(getName(), (Object[]) getValue()));
		break;
	default:
		restriction = Restrictions.eq(getName(), getValue());
		break;
	}
	return restriction;
}
 
源代码2 项目: Lottery   文件: CmsDictionaryDaoImpl.java
@SuppressWarnings("unchecked")
public CmsDictionary findByValue(String type,String value){
	Criterion cron_type=null,cron_value=null;
	if(StringUtils.isNotBlank(type)){
		cron_type = Restrictions.like("type",type);
	}
	if(StringUtils.isNotBlank(value)){
		cron_value = Restrictions.like("value",value);
	}
	List<CmsDictionary>li=findByCriteria(cron_type,cron_value);
	if(li!=null&&li.size()>0){
		return li.get(0);
	}else{
		return null;
	}
}
 
源代码3 项目: DWSurvey   文件: HibernateDao.java
/**
 * 按属性条件参数创建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;
}
 
源代码4 项目: ctsms   文件: CategoryCriterion.java
public static Criterion getCategoryCriterionRestriction(CategoryCriterion categoryCriterion) {
	Criterion restriction = null;
	if (categoryCriterion.prefix != null && categoryCriterion.prefix.length() > 0) {
		if (categoryCriterion.caseSensitive) {
			restriction = Restrictions.like(categoryCriterion.field, categoryCriterion.prefix, categoryCriterion.matchMode);
		} else {
			restriction = Restrictions.ilike(categoryCriterion.field, categoryCriterion.prefix, categoryCriterion.matchMode);
		}
	} else if (EmptyPrefixModes.NON_EMPTY_ROWS.equals(categoryCriterion.emptyPrefixMode)) {
		restriction = Restrictions.not(Restrictions.or(Restrictions.eq(categoryCriterion.field, ""), Restrictions.isNull(categoryCriterion.field)));
	} else if (EmptyPrefixModes.EMPTY_ROWS.equals(categoryCriterion.emptyPrefixMode)) {
		restriction = Restrictions.or(Restrictions.eq(categoryCriterion.field, ""), Restrictions.isNull(categoryCriterion.field));
	}
	return restriction;
}
 
源代码5 项目: dhis2-core   文件: LikeOperator.java
@Override
public Criterion getHibernateCriterion( QueryPath queryPath )
{
    if ( caseSensitive )
    {
        return Restrictions.like( queryPath.getPath(), String.valueOf( args.get( 0 ) ).replace( "%", "\\%" ), matchMode );
    }
    else
    {
        return Restrictions.ilike( queryPath.getPath(), String.valueOf( args.get( 0 ) ).replace( "%", "\\%" ), matchMode );
    }
}
 
源代码6 项目: Lottery   文件: CmsDictionaryDaoImpl.java
public Pagination getPage(String queryType,int pageNo, int pageSize) {
	Criteria crit = createCriteria();
	if(StringUtils.isNotBlank(queryType)){
		Criterion cron = Restrictions.like("type",queryType);
		crit.add(cron);
	}
	Pagination page = findByCriteria(crit, pageNo, pageSize);
	return page;
}
 
源代码7 项目: geomajas-project-server   文件: CriteriaVisitor.java
/** {@inheritDoc} */
@Override
public Object visit(PropertyIsLike filter, Object userData) {
	String propertyName = getPropertyName(filter.getExpression());
	String finalName = parsePropertyName(propertyName, userData);

	String value = filter.getLiteral();
	value = value.replaceAll("\\*", "%");
	value = value.replaceAll("\\?", "_");
	if (filter.isMatchingCase()) {
		return Restrictions.like(finalName, value);
	} else {
		return Restrictions.ilike(finalName, value);
	}
}
 
源代码8 项目: Lottery   文件: CmsDictionaryDaoImpl.java
@SuppressWarnings("unchecked")
public List<CmsDictionary> getList(String type){
	Criterion cron = Restrictions.like("type",type); 
	return findByCriteria(cron);
}
 
源代码9 项目: base-framework   文件: LikeRestriction.java
public Criterion build(String propertyName, Object value) {
	return Restrictions.like(propertyName, value.toString(), MatchMode.ANYWHERE);
}
 
源代码10 项目: lemon   文件: HibernateUtils.java
/**
 * 按属性条件参数创建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;
}
 
源代码11 项目: base-framework   文件: LLikeRestriction.java
public Criterion build(String propertyName, Object value) {
	
	return Restrictions.like(propertyName, value.toString(), MatchMode.END);
}
 
源代码12 项目: base-framework   文件: RLikeRestriction.java
public Criterion build(String propertyName, Object value) {
	
	return Restrictions.like(propertyName, value.toString(), MatchMode.START);
}