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


Java CriteriaBuilder.like方法代码示例

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


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

示例1: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(Root<TestSuite> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
	Predicate result = null;

	if (StringUtils.isNotEmpty(filter.getSuite())) {
		result = criteriaBuilder.like(criteriaBuilder.lower(root.get(SUITE_PROPERTY)),
				buildLikeValue(filter.getSuite()));
	}

	return result;
}
 
开发者ID:ATLANTBH,项目名称:owl,代码行数:12,代码来源:TestSuiteFilterSpecification.java

示例2: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })  
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query,  
        CriteriaBuilder builder) {  
    Path expression = null;  
    if(fieldName.contains(".")){  
        String[] names = StringUtils.split(fieldName, ".");  
        expression = root.get(names[0]);  
        for (int i = 1; i < names.length; i++) {  
            expression = expression.get(names[i]);  
        }  
    }else{  
        expression = root.get(fieldName);  
    }  
    
    switch (operator) {  
    case EQ:  
        return builder.equal(expression, value);  
    case NE:  
        return builder.notEqual(expression, value);  
    case LIKE:  
        return builder.like((Expression<String>) expression, "%" + value + "%");  
    case LT:  
        return builder.lessThan(expression, (Comparable) value);  
    case GT:  
        return builder.greaterThan(expression, (Comparable) value);  
    case LTE:  
        return builder.lessThanOrEqualTo(expression, (Comparable) value);  
    case GTE:  
        return builder.greaterThanOrEqualTo(expression, (Comparable) value);  
    default:  
        return null;  
    }  
}
 
开发者ID:wengwh,项目名称:plumdo-work,代码行数:34,代码来源:SimpleExpression.java

示例3: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(final Root<?> leveringsautorisatieRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<Dienstbundel> dienstbundelRoot = query.from(Dienstbundel.class);

    // Join dienst op leveringsautorisatie
    final Predicate joinPredicateLeveringsautorisatie = leveringsautorisatieRoot.get(ID).in(dienstbundelRoot.get(LEVERINGSAUTORISATIE).get(ID));

    // Dienstbundel
    final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, dienstbundelRoot.get("naam")));
    final Expression<String> valueExpression =
            cb.lower(
                    cb.function(
                            UNACCENT,
                            String.class,
                            cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
    final Predicate dienstBundelPredicate = cb.like(attributeExpression, valueExpression);

    return cb.and(joinPredicateLeveringsautorisatie, dienstBundelPredicate);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:LeveringsautorisatieFilterFactory.java

示例4: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(final Root<?> persoonRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<PersoonAdres> persoonAdressenRoot = query.from(PersoonAdres.class);
    final Predicate joinPredicateAdressen = persoonRoot.get(ID).in(persoonAdressenRoot.get(PERSOON).get(ID));
    final Predicate adresPredicate;
    if (likePredicate) {
        final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get(field)));
        final Expression<String> valueExpression =
                cb.lower(
                        cb.function(
                                UNACCENT,
                                String.class,
                                cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
        adresPredicate = cb.like(attributeExpression, valueExpression);
    } else {
        adresPredicate = cb.equal(persoonAdressenRoot.get(field), value);
    }
    return cb.and(joinPredicateAdressen, adresPredicate);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:PersoonFilterFactory.java

示例5: buildPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings ({ "unchecked", "rawtypes" })
protected Predicate buildPredicate(Path<T> root, SearchField field)
{
	Path<T> tt = (!field.getField().contains(".")) ? root.get(field.getField()) : fetchNestedPath(root, field.getField());
	CriteriaBuilder criteriaBuilder = this.entitymanager.getCriteriaBuilder();
	
	Class<?> javaType = tt.getJavaType();
	
	if (!classCompatibleWithOperator(javaType, field.getOperator()))
	{
		throw new RuntimeException("operator incompatible with field");
	}
	
	Object valueObject = convertStringValueToObject(field.getValue(), javaType);
	switch (field.getOperator())
	{
		case GE:
			return criteriaBuilder.greaterThan((Expression) tt, (Comparable) valueObject);
		case GTE:
			return criteriaBuilder.greaterThanOrEqualTo((Expression) tt, (Comparable) valueObject);
		case LE:
			return criteriaBuilder.lessThan((Expression) tt, (Comparable) valueObject);
		case LTE:
			return criteriaBuilder.lessThanOrEqualTo((Expression) tt, (Comparable) valueObject);
		case NE: 
               return criteriaBuilder.notEqual(tt, valueObject); 
		case EX:
			return criteriaBuilder.like((Expression) tt, "%"+field.getValue()+"%");
		default:
		{
			//EQ
			return criteriaBuilder.equal(tt, valueObject);
		}
	}
}
 
开发者ID:tairmansd,项目名称:CriteriaBuilder,代码行数:36,代码来源:CriteriaServiceImpl.java

示例6: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(final Root<?> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    // Like en case insensitive
    final Path<String> path = PredicateBuilderUtil.<String>getPath(root, naam);
    final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, path));
    final Expression<String> valueExpression =
            cb.lower(cb.function(UNACCENT, String.class, cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));

    return cb.like(attributeExpression, valueExpression);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:11,代码来源:LikePredicateBuilder.java

示例7: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
    Path expression = null;
    if (fieldName.contains(".")) {
        
        System.out.println(root);
        String[] names = StringUtils.split(fieldName, ".");
        expression = root.get(names[0]);
        for (int i = 1; i < names.length; i++) {
            expression = expression.get(names[i]);
        }
    } else {
        expression = root.get(fieldName);
    }

    switch (operator) {
    case EQ:
        return builder.equal(expression, value);
    case NE:
        return builder.notEqual(expression, value);
    case LIKE:
        return builder.like((Expression<String>) expression, "%" + value + "%");
    case RLIKE:
        return builder.like((Expression<String>) expression, value + "%");
    case LLIKE:
        return builder.like((Expression<String>) expression, value + "%");
    case LT:
        return builder.lessThan(expression, (Comparable) value);
    case GT:
        return builder.greaterThan(expression, (Comparable) value);
    case LTE:
        return builder.lessThanOrEqualTo(expression, (Comparable) value);
    case GTE:
        return builder.greaterThanOrEqualTo(expression, (Comparable) value);
    case ISNULL:
        return builder.isNull(expression);
    case NOTNULL:
        return builder.isNotNull(expression);
    default:
        return null;
    }
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:43,代码来源:SimpleExpression.java

示例8: buildJpaPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate buildJpaPredicate(CriteriaBuilder builder, Root<?> root) {
	Expression<String> path = QueryFormHelper.getPath(root, field);
	return builder.like(path, "%" + value + "%");
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:6,代码来源:Contains.java

示例9: buildJpaPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate buildJpaPredicate(CriteriaBuilder builder, Root<?> root) {
	Expression<String> path = QueryFormHelper.getPath(root, field);
	return builder.like(path, "%" + value);
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:6,代码来源:EndWith.java

示例10: buildJpaPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate buildJpaPredicate(CriteriaBuilder builder, Root<?> root) {
	Expression<String> path = QueryFormHelper.getPath(root, field);
	return builder.like(path, value + "%");
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:6,代码来源:StartWith.java

示例11: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(Criterion c, Root<?> r, CriteriaBuilder b) {
    return b.like(
            r.get(c.getPropertyName()), getString(c));
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:6,代码来源:Criterion.java

示例12: searchValueset

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
public List<ValueSet> searchValueset (
        @OptionalParam(name = ValueSet.SP_NAME) StringParam name
)
{
    List<ValueSetEntity> qryResults = null;

    CriteriaBuilder builder = em.getCriteriaBuilder();

    CriteriaQuery<ValueSetEntity> criteria = builder.createQuery(ValueSetEntity.class);
    Root<ValueSetEntity> root = criteria.from(ValueSetEntity.class);
   

    List<Predicate> predList = new LinkedList<Predicate>();
    List<ValueSet> results = new ArrayList<ValueSet>();

    if (name !=null)
    {

        Predicate p =
                builder.like(
                        builder.upper(root.get("name").as(String.class)),
                        builder.upper(builder.literal("%"+name.getValue()+"%"))
                );

        predList.add(p);
    }

   

    Predicate[] predArray = new Predicate[predList.size()];
    predList.toArray(predArray);
    if (predList.size()>0)
    {
        criteria.select(root).where(predArray);
    }
    else
    {
        criteria.select(root);
    }

    qryResults = em.createQuery(criteria).getResultList();

    for (ValueSetEntity valuesetEntity : qryResults)
    {
        ValueSet valueset = valuesetEntityToFHIRValuesetTransformer.transform(valuesetEntity);
        results.add(valueset);
    }

    return results;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:51,代码来源:RIValueSetRepository.java

示例13: searchValueset

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
public List<ValueSet> searchValueset (
        @OptionalParam(name = ValueSet.SP_NAME) StringParam name
)
{
    List<ValueSetEntity> qryResults = null;

    CriteriaBuilder builder = em.getCriteriaBuilder();

    CriteriaQuery<ValueSetEntity> criteria = builder.createQuery(ValueSetEntity.class);
    Root<ValueSetEntity> root = criteria.from(ValueSetEntity.class);
   

    List<Predicate> predList = new LinkedList<Predicate>();
    List<ValueSet> results = new ArrayList<ValueSet>();

    if (name !=null)
    {

        Predicate p =
                builder.like(
                        builder.upper(root.get("name").as(String.class)),
                        builder.upper(builder.literal(name.getValue()+"%"))
                );

        predList.add(p);
    }

   

    Predicate[] predArray = new Predicate[predList.size()];
    predList.toArray(predArray);
    if (predList.size()>0)
    {
        criteria.select(root).where(predArray);
    }
    else
    {
        criteria.select(root);
    }

    qryResults = em.createQuery(criteria).getResultList();

    for (ValueSetEntity valuesetEntity : qryResults)
    {
        ValueSet valueset = valuesetEntityToFHIRValuesetTransformer.transform(valuesetEntity);
        results.add(valueset);
    }

    return results;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:51,代码来源:ValueSetDao.java


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