Package org.hibernate.criterion

Examples of org.hibernate.criterion.Disjunction


    Set<Class<?>> indexedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class<?>[] { entityType } );
    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getIndexBindingForEntity(
        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


    DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( indexedEntities.iterator().next() );
    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

     */
    public static void applyTextSearchCriteria(
            CriteriaDescriptor criteriaDescriptor,
            Collection<String> searchableFields, String query) {
        if(searchableFields != null && !searchableFields.isEmpty()) {
            Disjunction disjunction = Restrictions.disjunction();
            for(String field: searchableFields) {
                String scalarSearchField = criteriaDescriptor.getFieldAlias(field);
                disjunction.add(Restrictions.like(scalarSearchField, query,
                        MatchMode.ANYWHERE));
            }
            Criteria rootCriteria = criteriaDescriptor.getCriteria();
            rootCriteria.add(disjunction);
        }
View Full Code Here

            protected void processCriteria(Criteria criteria,
                    CriteriaDescriptor criteriaDescriptor, boolean isCount) {
                DetachedCriteria relatedResourcesCriteria = DetachedCriteria.forClass(Resource.class);
                relatedResourcesCriteria.createCriteria(Resource.FIELD_SUPPLIES, "_supplies", Criteria.LEFT_JOIN);
                relatedResourcesCriteria.createCriteria(Resource.FIELD_NEEDS, "_needs", Criteria.LEFT_JOIN);
                Disjunction userIdRestriction = Restrictions.disjunction();
                userIdRestriction.add(Restrictions.eq(Resource.FIELD_OWNER + "." + User.FIELD_ID(), userId));
                userIdRestriction.add(Restrictions.eq("_supplies." + Supply.FIELD_USER + "." + User.FIELD_ID(), userId));
                userIdRestriction.add(Restrictions.eq("_needs." + Need.FIELD_USER + "." + User.FIELD_ID(), userId));
                relatedResourcesCriteria.add(userIdRestriction);
                relatedResourcesCriteria.setProjection(Projections.distinct(Projections.property(Resource.FIELD_ID())));
                criteria.add(Subqueries.propertyIn(Resource.FIELD_ID(), relatedResourcesCriteria));
            }
        };
View Full Code Here

  public List<Event> getRandom(int num) {
    Criteria c = sessionStrategy.getCurrentSession().createCriteria(Event.class);
   
    Long eventCount = eventDAO.count();
   
    Disjunction element_or = Restrictions.disjunction();
   
    for(; num > 0; num--) {
      long next = rand.nextLong() % eventCount + 1;
      next = next < 0 ? -next : next;
      element_or.add(Restrictions.eq("id", next));
    }
   
    c.add(element_or);
   
    return (List<Event>)c.list();
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].id );
      }
      disjunction.add( Restrictions.in( idName, ids ) );
    }
    criteria.add( disjunction );
    //not best effort so fail fast
    if ( ! timeoutManager.isBestEffort() ) {
      final Long timeLeftInSecond = timeoutManager.getTimeoutLeftInSeconds();
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.