本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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[] {}));
}
示例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);
}
示例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);
}
示例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()]));
}
示例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;
}
}
示例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));
}
示例10: combine
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate combine(CriteriaBuilder builder, Predicate lhs, Predicate rhs) {
return builder.or(lhs, rhs);
}