javax.persistence.criteria.Predicate.getOperator()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中javax.persistence.criteria.Predicate.getOperator()方法的一些代码示例,展示了Predicate.getOperator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Predicate.getOperator()方法的具体详情如下:
包路径:javax.persistence.criteria.Predicate
类名称:Predicate
方法名:getOperator

Predicate.getOperator介绍

[英]Return the boolean operator for the predicate. If the predicate is simple, this is AND.
[中]返回谓词的布尔运算符。如果谓词很简单,则为[$0$]。

代码示例

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Create a predicate testing for a false value.
 * 
 * @param x
 *            expression to be tested if false
 * @return predicate
 */
public Predicate isFalse(Expression<Boolean> x){
  if (((InternalExpression)x).isPredicate()){
    if (((InternalSelection)x).getCurrentNode() == null){
      if (((Predicate)x).getOperator() == BooleanOperator.AND){
        return (Predicate)x;
      }else{
        return this.conjunction();
      }
    }else{
      throw new IllegalArgumentException(ExceptionLocalization.buildMessage("PREDICATE_PASSED_TO_EVALUATION"));
    }
  }
  return new CompoundExpressionImpl(this.metamodel, ((InternalSelection)x).getCurrentNode().equal(false), buildList(x), "equals");
}

代码示例来源:origin: FINRAOS/herd

@Test
public void testGetPredicateForInClauseTwoChunks()
{
  // Create the JPA builder, query, and entity root.
  CriteriaBuilder builder = entityManager.getCriteriaBuilder();
  CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class);
  Root<BusinessObjectDataEntity> businessObjectDataEntity = criteria.from(BusinessObjectDataEntity.class);
  // Get the predicate for the "in" clause with 1001 values (1 greater than the default chunking size).
  Predicate predicate = baseJpaDaoImpl
    .getPredicateForInClause(builder, businessObjectDataEntity.get(BusinessObjectDataEntity_.partitionValue), getPartitionValueList(1001));
  // We expect to get back an "or" of 2 "in" expressions where each "in" expression is a list of chunked partition values.
  assertEquals(Predicate.BooleanOperator.OR, predicate.getOperator());
  List<Expression<Boolean>> expressions = predicate.getExpressions();
  assertEquals(2, expressions.size());
  // The first "in" clause will have the first 1000 elements and the second "in" clause will have the extra "1" element.
  assertEquals(1000, ((InPredicate) expressions.get(0)).getValues().size());
  assertEquals(1, ((InPredicate) expressions.get(1)).getValues().size());
}

相关文章