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


Java CriteriaBuilder.or方法代码示例

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


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

示例1: getPredicateGlobalSearch

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
private Predicate getPredicateGlobalSearch(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb,
    Predicate predicate) {
    // check whether a global filter value exists
    final String globalFilterValue = input.getSearch().getValue();
    if (globalFilterValue != null && globalFilterValue.trim().length() > 0) {
        LOGGER.fine("filtre global: {"+ globalFilterValue+"}");

        Predicate matchOneColumnPredicate = cb.disjunction();
        // add a 'WHERE .. LIKE' clause on each searchable column
        for (final DatatableColumn column : input.getColumns()) {
            if (column.getSearchable()) {
                LOGGER.log(Level.FINE, "filtre global pour colonne: {}", column);
                final Expression<String> expression = DatatableHelper.getExpression(root, column.getData(), String.class);

                matchOneColumnPredicate = cb.or(matchOneColumnPredicate,
                    cb.like(cb.lower(expression), getLikeFilterValue(globalFilterValue), ESCAPE_CHAR));
            }
        }
        predicate = cb.and(predicate, matchOneColumnPredicate);
    }
    return predicate;
}
 
开发者ID:andresoviedo,项目名称:datatable-java,代码行数:23,代码来源:DatatableSpecification.java

示例2: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query,  
        CriteriaBuilder builder) {  
    List<Predicate> predicates = new ArrayList<Predicate>();  
    for(int i=0;i<this.criterion.length;i++){  
        predicates.add(this.criterion[i].toPredicate(root, query, builder));  
    }  
    switch (operator) {  
    case OR:  
        return builder.or(predicates.toArray(new Predicate[predicates.size()]));  
    default:  
        return null;  
    }  
}
 
开发者ID:wengwh,项目名称:plumdo-stock,代码行数:14,代码来源:LogicalExpression.java

示例3: buildPredicateWithOperator

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
protected Predicate buildPredicateWithOperator(Path<T> tt, Conjunctions conjunctions, List<Predicate> predicateList) {
	CriteriaBuilder criteriaBuilder = this.entitymanager.getCriteriaBuilder();
	Predicate predicate = null;
	if(conjunctions.equals(Conjunctions.AND)) {
		predicate = criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
	} else if(conjunctions.equals(Conjunctions.OR)) {
		predicate = criteriaBuilder.or(predicateList.toArray(new Predicate[predicateList.size()]));
	}
	return predicate;
}
 
开发者ID:tairmansd,项目名称:CriteriaBuilder,代码行数:11,代码来源:CriteriaServiceImpl.java

示例4: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(final Root<?> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final List<Predicate> predicates = new ArrayList<>();

    for (final PredicateBuilder predicateBuilder : predicateBuilders) {
        final Predicate predicate = predicateBuilder.toPredicate(root, query, cb);
        if (predicate != null) {
            predicates.add(predicate);
        }
    }

    return cb.or(predicates.toArray(new Predicate[] {}));
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:14,代码来源:OrPredicateBuilder.java

示例5: 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 Expression<String> attributeExpression1 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel1")));
    final Expression<String> attributeExpression2 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel2")));
    final Expression<String> attributeExpression3 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel3")));
    final Expression<String> attributeExpression4 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel4")));
    final Expression<String> attributeExpression5 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel5")));
    final Expression<String> attributeExpression6 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel6")));
    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 adresPredicate1 = cb.like(attributeExpression1, valueExpression);
    final Predicate adresPredicate2 = cb.like(attributeExpression2, valueExpression);
    final Predicate adresPredicate3 = cb.like(attributeExpression3, valueExpression);
    final Predicate adresPredicate4 = cb.like(attributeExpression4, valueExpression);
    final Predicate adresPredicate5 = cb.like(attributeExpression5, valueExpression);
    final Predicate adresPredicate6 = cb.like(attributeExpression6, valueExpression);

    final Predicate buitenlandsAdres = cb.or(adresPredicate1, adresPredicate2, adresPredicate3, adresPredicate4, adresPredicate5, adresPredicate6);
    return cb.and(joinPredicateAdressen, buitenlandsAdres);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:34,代码来源:PersoonFilterFactory.java

示例6: getGroupPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
/**
 * Create a predicate group.
 */
private Predicate getGroupPredicate(final UiFilter group, final Root<U> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
	// Build the predicates
	final java.util.List<Predicate> predicates = getPredicates(group, root, query, cb);

	// Build the specification
	if (predicates.isEmpty()) {
		return cb.conjunction();
	}
	final Predicate[] filteredPredicates = predicates.toArray(new Predicate[predicates.size()]);
	if (group.getGroupOp() == FilterOperator.AND) {
		return cb.and(filteredPredicates);
	}
	return cb.or(filteredPredicates);
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:18,代码来源:DynamicSpecification.java

示例7: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Predicate toPredicate(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {

	LOGGER.log(Level.FINE, "Creating OR search predicate: '{}':'{}'", new Object[]{search, colonnes});

    // liste de predicats pour aprés faire le "or"
    final List<Predicate> predicates = new ArrayList<Predicate>();

    // valeur a chercher
    final String valeurRecherche = search.getValue().trim().toLowerCase();

    for (final DatatableColumn colonne : colonnes) {
        final Path<?> expression = DatatableHelper.getExpression(root, colonne.getData(), null);
        if (expression.getJavaType() == String.class) {
            String valuerFinale = valeurRecherche;
            if (colonne.isSearchWithoutSpaces()) {
                // le siret par exemple no contient pas des espaces
                valuerFinale = valeurRecherche.replace(" ", "");
            }
            predicates.add(cb.like(cb.lower(expression.as(String.class)),
                DatatableSpecification.getLikeFilterValue(valuerFinale),
                DatatableSpecification.ESCAPE_CHAR));
        } else if (expression.getJavaType() == Integer.class) {
            predicates.add(cb.like(expression.as(String.class),
                DatatableSpecification.getLikeFilterValue(valeurRecherche),
                DatatableSpecification.ESCAPE_CHAR));
        } else {
            throw new IllegalArgumentException("La colonne n'a pas le type supporté [String.class|Integer.class] ("
                + expression.getJavaType() + ")");
        }
    }

    return cb.or(predicates.toArray(new Predicate[predicates.size()]));
}
 
开发者ID:andresoviedo,项目名称:datatable-java,代码行数:38,代码来源:DatatableOrSpecification.java

示例8: toPredicate

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
    List<Predicate> predicates = new ArrayList<Predicate>();
    for (int i = 0; i < this.criterion.length; i++) {
        predicates.add(this.criterion[i].toPredicate(root, query, builder));
    }
    switch (operator) {
    case OR:
        return builder.or(predicates.toArray(new Predicate[predicates.size()]));
    default:
        return null;
    }
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:14,代码来源:LogicalExpression.java

示例9: buildJpaPredicate

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

示例10: combine

import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate combine(CriteriaBuilder builder, Predicate lhs, Predicate rhs) {
	return builder.or(lhs, rhs);
}
 
开发者ID:andresoviedo,项目名称:datatable-java,代码行数:5,代码来源:Specifications.java


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