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

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

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

Predicate.getExpressions介绍

[英]Return the top-level conjuncts or disjuncts of the predicate. Returns empty list if there are no top-level conjuncts or disjuncts of the predicate. Modifications to the list do not affect the query.
[中]返回谓词的顶级连接或断开。如果谓词没有顶级连接或断开,则返回空列表。对列表的修改不会影响查询。

代码示例

代码示例来源:origin: Impetus/Kundera

List<Expression<Boolean>> expressions = where.getExpressions();
for (Expression expr : expressions)

代码示例来源:origin: stackoverflow.com

private Specification<Event> buildSpecification(final EventFilter filter) {
   final Specification<Event> specification = new Specification<Event>() {
     @Override
     public Predicate toPredicate(Root<Event> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
       cq.distinct(true);
       Predicate predicate = cb.conjunction();
       if (filter.getEventGroupIds() != null) {
         Join<Event, EventGroup> join = root.join(Event_.eventGroups);
         predicate.getExpressions().add(join.get(EventGroup_.id).in(filter.getEventGroupIds()) );
       }
       return predicate;
     }
   };
   return specification;
 }

代码示例来源:origin: dhis2/dhis2-core

@Override
public int count( DeletedObjectQuery query )
{
  CriteriaBuilder builder = getCurrentSession().getCriteriaBuilder();
  CriteriaQuery<Long> criteriaQuery = builder.createQuery( Long.class );
  Root<DeletedObject> root = criteriaQuery.from( DeletedObject.class );
  Predicate predicate = buildCriteria( builder, root, query );
  criteriaQuery.select( builder.countDistinct( root ) );
  if ( !predicate.getExpressions().isEmpty() ) criteriaQuery.where( predicate );
  Query<Long> typedQuery = getCurrentSession().createQuery( criteriaQuery );
  return typedQuery.getSingleResult().intValue();
}

代码示例来源:origin: dhis2/dhis2-core

disjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
  disjunction.getExpressions().add( root.get( "code" ).in( query.getCode() ) );
if ( !disjunction.getExpressions().isEmpty() ) predicate.getExpressions().add( disjunction );
predicate.getExpressions().add( builder.or( root.get( "klass" ).in( query.getKlass() ),
  root.get( "klass" ).in( query.getKlass() ) ) );
  conjunction.getExpressions().add( root.get( "klass" ).in( query.getKlass() ) );
  conjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
  disjunction.getExpressions().add( conjunction );
  conjunction.getExpressions().add( root.get( "klass" ).in( query.getKlass() ) );
  conjunction.getExpressions().add( root.get( "code" ).in( query.getUid() ) );
  disjunction.getExpressions().add( conjunction );
if ( !disjunction.getExpressions().isEmpty() ) predicate.getExpressions().add( disjunction );
predicate.getExpressions().add( builder.greaterThanOrEqualTo( root.get( "deletedAt" ), query.getDeletedAt() ) );

代码示例来源:origin: stackoverflow.com

if(whereClause.getExpressions().isEmpty()) {
  throw new RuntimeException("no criteria");

代码示例来源:origin: dhis2/dhis2-core

@Override
public List<DeletedObject> query( DeletedObjectQuery query )
{
  CriteriaBuilder builder = getCurrentSession().getCriteriaBuilder();
  CriteriaQuery<DeletedObject> criteriaQuery = builder.createQuery( DeletedObject.class );
  Root<DeletedObject> root = criteriaQuery.from( DeletedObject.class );
  Predicate predicate = buildCriteria( builder, root, query );
  criteriaQuery.select( root );
  if ( !predicate.getExpressions().isEmpty() ) criteriaQuery.where( predicate );
  Query<DeletedObject> typedQuery = getCurrentSession().createQuery( criteriaQuery );
  if ( !query.isSkipPaging() )
  {
    Pager pager = query.getPager();
    typedQuery.setFirstResult( pager.getOffset() );
    typedQuery.setMaxResults( pager.getPageSize() );
  }
  return typedQuery.list();
}

代码示例来源:origin: dhis2/dhis2-core

conjunction.getExpressions().add( predicate );

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    builder.or(builder.greaterThanOrEqualTo(root.<Date> get(expiryProperty.getName()), new Date()),
        builder.isNull(root.<Date> get(expiryProperty.getName()))));

代码示例来源:origin: dhis2/dhis2-core

disjunction.getExpressions().add( root.get( "uid" ).in( query.getUid() ) );
disjunction.getExpressions().add( root.get( "code" ).in( query.getCode() ) );
disjunction.getExpressions().add( conjunction );
disjunction.getExpressions().add( conjunction );

代码示例来源:origin: com.github.dactiv/dactiv-orm

public Predicate build(PropertyFilter filter,SpecificationEntity entity) {
  String matchValue = filter.getMatchValue();
  Class<?> FieldType = filter.getFieldType();
  
  MatchValue matchValueModel = getMatchValue(matchValue, FieldType);
  
  Predicate predicate = null;
  
  if (matchValueModel.hasOrOperate()) {
    predicate = entity.getBuilder().disjunction();
  } else {
    predicate = entity.getBuilder().conjunction();
  }
  
  for (Object value : matchValueModel.getValues()) {
    if (filter.hasMultiplePropertyNames()) {
      for (String propertyName:filter.getPropertyNames()) {
        predicate.getExpressions().add(build(propertyName, value, entity));
      }
    } else {
      predicate.getExpressions().add(build(filter.getSinglePropertyName(), value, entity));
    }
  }
  
  return predicate;
}

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    criteria.getBuilder().equal(fromProject.get(roleModelProperty.getName()), criteria.getRoot()));
conjunction.getExpressions().add(
    criteria.getBuilder().equal(fromProject.get(memberModelProperty.getName()), store.lookupIdentityObjectById((IdentityType) object)));

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(memberModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getMember())));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(roleModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getRole())));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(groupModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getGroup())));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(groupModelProperty.getName()), store.lookupIdentityObjectById(new SimpleGroup(object.toString()))));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(roleModelProperty.getName()), store.lookupIdentityObjectById(new SimpleRole(object.toString()))));

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(memberModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getMember())));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(roleModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getRole())));
  conjunction.getExpressions().add(
      builder.equal(fromProject.get(groupModelProperty.getName()), store.lookupIdentityObjectById(groupRole.getGroup())));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(groupModelProperty.getName()), store.lookupIdentityObjectById(new SimpleGroup(object.toString()))));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(memberModelProperty.getName()), root));
conjunction.getExpressions().add(
    builder.equal(fromProject.get(roleModelProperty.getName()), store.lookupIdentityObjectById(new SimpleRole(object.toString()))));

代码示例来源: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());
}

代码示例来源:origin: com.github.dactiv/dactiv-orm

public Predicate build(PropertyFilter filter, SpecificationEntity entity) {
  Object value = convertMatchValue(filter.getMatchValue(), filter.getFieldType());
  Predicate predicate = null;
  
  if (filter.hasMultiplePropertyNames()) {
    Predicate orDisjunction = entity.getBuilder().disjunction();
    for (String propertyName:filter.getPropertyNames()) {
      orDisjunction.getExpressions().add(build(propertyName,value,entity));
    }
    predicate = orDisjunction;
  } else {
    predicate = build(filter.getSinglePropertyName(),value,entity);
  }
  
  return predicate;
}

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    criteria.getBuilder().equal(fromProject.get(groupModelProperty.getName()), criteria.getRoot()));
conjunction.getExpressions().add(
    criteria.getBuilder().equal(fromProject.get(memberModelProperty.getName()), store.lookupIdentityObjectById((IdentityType) object)));

代码示例来源:origin: org.picketlink/picketlink-idm-impl

conjunction.getExpressions().add(
    criteria.getBuilder().equal(fromProject.get(storeConfig.getModelProperty(PROPERTY_ATTRIBUTE_NAME).getName()),
        customParameter.getName()));
conjunction.getExpressions().add(
    (fromProject.get(storeConfig.getModelProperty(PROPERTY_ATTRIBUTE_VALUE).getName()).in((Object[]) parameterValues)));

相关文章