Package org.hibernate.criterion

Examples of org.hibernate.criterion.Disjunction


*/
public class FactFilterBuilder extends FilterBuilder {

    @Override
    protected Criterion buildCriteriaForKey(String key, List<String> values) {
        Disjunction valuesCriteria = Restrictions.disjunction();
        for (String value : values) {
            if (StringUtils.isEmpty(value)) {
                valuesCriteria.add(Restrictions.isNull("cfacts.elements"));
                valuesCriteria.add(Restrictions.eq("cfacts.elements", ""));
            }
            else {
                valuesCriteria.add(new FilterLikeExpression("cfacts.elements", value, true));
            }
        }

        DetachedCriteria dc = DetachedCriteria.forClass(Consumer.class, "subcons")
            .add(Restrictions.eqProperty("this.id", "subcons.id"))
View Full Code Here


     * @param matches Text to search for in various fields on the pool. Basic
     * wildcards are supported for everything or a single character. (* and ? respectively)
     */
    public void addMatchesFilter(String matches) {

        Disjunction textOr = Restrictions.disjunction();
        textOr.add(new FilterLikeExpression("productName", matches, true));
        textOr.add(new FilterLikeExpression("productId", matches, true));
        textOr.add(new FilterLikeExpression("contractNumber", matches, true));
        textOr.add(new FilterLikeExpression("orderNumber", matches, true));
        textOr.add(Subqueries.exists(
                createProvidedProductCriteria(matches)));
        textOr.add(Subqueries.exists(
                createAttributeCriteria(ProductPoolAttribute.class, "support_level",
                Arrays.asList(matches))));
        this.otherCriteria.add(textOr);
    }
View Full Code Here

    if (id != null) {
      criteria.add(Restrictions.not(Restrictions.eq("id", (id == null ? 0
          : id)))); // restrição do ítem atual
    }
    /** para permitir pesquisar em mais de um campo */
    Disjunction disjunction = Restrictions.disjunction();
    for (String f : field.split(",")) {
      disjunction.add(Restrictions.sqlRestriction(
          String.format("%s::text = ?", f.trim()), value,
          StringType.INSTANCE)); // restrição pelo valor do campo)
    }

    criteria.add(disjunction);
View Full Code Here

    return criterion;
  }

  public void buildCriteria(String propertyName) throws MalformedRangeExpression {
    String[] clauses = getText().trim().split("[ \t]*[;,][ \t]*");
    Disjunction result = Restrictions.disjunction();
    for (String clause : clauses) {
      Criterion c = makeRestriction(propertyName, new Bounds(clause));
      if (c != null) result.add(c);
    }
    criterion = result;
  }
View Full Code Here

    Set<Class<?>> indexedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class<?>[] { entityType } );
    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getIndexBinding(
        indexedEntities.iterator().next()
    ).getDocumentBuilder();
    String idName = builder.getIdentifierName();
    Disjunction disjunction = Restrictions.disjunction();

    int loop = maxResults / MAX_IN_CLAUSE;
    boolean exact = maxResults % MAX_IN_CLAUSE == 0;
    if ( !exact ) {
      loop++;
    }
    for ( int index = 0; index < loop; index++ ) {
      int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
          index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
          maxResults;
      List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
      for ( int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++ ) {
        ids.add( entityInfos[entityInfoIndex].getId() );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    //not best effort so fail fast
    if ( timeoutManager.getType() != TimeoutManager.Type.LIMIT ) {
      Long timeLeftInSecond = timeoutManager.getTimeoutLeftInSeconds();
View Full Code Here

    Set<Class<?>> indexedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class<?>[] { entityType } );
    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getDocumentBuilderIndexedEntity(
        indexedEntities.iterator().next()
    );
    String idName = builder.getIdentifierName();
    Disjunction disjunction = Restrictions.disjunction();

    int loop = maxResults / MAX_IN_CLAUSE;
    boolean exact = maxResults % MAX_IN_CLAUSE == 0;
    if ( !exact ) {
      loop++;
    }
    for ( int index = 0; index < loop; index++ ) {
      int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
          index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
          maxResults;
      List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
      for ( int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++ ) {
        ids.add( entityInfos[entityInfoIndex].getId() );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    //not best effort so fail fast
    if ( timeoutManager.getType() != TimeoutManager.Type.LIMIT ) {
      Long timeLeftInSecond = timeoutManager.getTimeoutLeftInSeconds();
View Full Code Here

        List ids = new ArrayList<SomeEntityId>(2);
        ids.add( new SomeEntityId(1,12) );
        ids.add( new SomeEntityId(10,23) );

        Criteria criteria = s.createCriteria( SomeEntity.class );
        Disjunction disjunction = Restrictions.disjunction();

        disjunction.add( Restrictions.in( "id", ids  ) );
        criteria.add( disjunction );

        List list = criteria.list();
        assertEquals( 2, list.size() );
    transaction.rollback();
View Full Code Here

    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
    String idName = builder.getIdentifierName();
    int loop = maxResults / MAX_IN_CLAUSE;
    boolean exact = maxResults % MAX_IN_CLAUSE == 0;
    if ( !exact ) loop++;
    Disjunction disjunction = Restrictions.disjunction();
    for (int index = 0; index < loop; index++) {
      int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
          index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
          maxResults;
      List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
      for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
        ids.add( entityInfos[entityInfoIndex].id );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    criteria.list(); //load all objects
  }
View Full Code Here

    Set<Class<?>> indexedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class<?>[] { entityType } );
    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getIndexBinding(
        indexedEntities.iterator().next()
    ).getDocumentBuilder();
    String idName = builder.getIdentifierName();
    Disjunction disjunction = Restrictions.disjunction();

    int loop = maxResults / MAX_IN_CLAUSE;
    boolean exact = maxResults % MAX_IN_CLAUSE == 0;
    if ( !exact ) {
      loop++;
    }
    for ( int index = 0; index < loop; index++ ) {
      int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
          index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
          maxResults;
      List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
      for ( int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++ ) {
        ids.add( entityInfos[entityInfoIndex].getId() );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    //not best effort so fail fast
    if ( timeoutManager.getType() != TimeoutManager.Type.LIMIT ) {
      Long timeLeftInSecond = timeoutManager.getTimeoutLeftInSeconds();
View Full Code Here

    DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get( entityType );
    String idName = builder.getIdentifierName();
    int loop = maxResults / MAX_IN_CLAUSE;
    boolean exact = maxResults % MAX_IN_CLAUSE == 0;
    if ( !exact ) loop++;
    Disjunction disjunction = Restrictions.disjunction();
    for (int index = 0; index < loop; index++) {
      int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
          index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
          maxResults;
      List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
      for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
        ids.add( entityInfos[entityInfoIndex].id );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    criteria.list(); //load all objects
  }
View Full Code Here

TOP

Related Classes of org.hibernate.criterion.Disjunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.