Examples of QueryByCriteria


Examples of org.apache.ojb.broker.query.QueryByCriteria

    /**
     * @todo is this supposed to operate outside of a user specified tx? Right now it obtains one if needed
     */
  public Iterator iterator()
  {
        QueryByCriteria q = QueryFactory.newQuery(m_clazz, m_criteria);
        ExtentIterator itty = new ExtentIterator((OJBIterator) m_conn.getIteratorByQuery(q));
        m_iterators.add(itty);
    return itty;
  }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

    }
    return query;
  }
 
  public final QueryByCriteria  selectQuery() throws RecognitionException, TokenStreamException {
    QueryByCriteria query = null;
   
   
    try {      // for error handling
     
      Class clazz = null;
      Criteria criteria = new Criteria();
      String[] projectionAttrs;
      boolean distinct = false;
     
      match(LITERAL_select);
      {
      if ((LA(1)==LITERAL_distinct)) {
        match(LITERAL_distinct);
       
        distinct = true;
       
      }
      else if ((LA(1)==TOK_STAR||LA(1)==Identifier)) {
      }
      else {
        throw new NoViableAltException(LT(1), getFilename());
      }
     
      }
      projectionAttrs=projectionAttributes();
      match(LITERAL_from);
      clazz=fromClause();
      {
      if ((LA(1)==LITERAL_where)) {
        match(LITERAL_where);
        whereClause(criteria);
      }
      else if ((_tokenSet_1.member(LA(1)))) {
      }
      else {
        throw new NoViableAltException(LT(1), getFilename());
      }
     
      }
     
      if (clazz != null)
      {
      if (projectionAttrs[0].indexOf('.') < 0)
      {
      query = QueryFactory.newQuery(clazz, criteria, distinct);
      }
      else
      {
      ClassDescriptor cld = MetadataManager.getInstance().getRepository().getDescriptorFor(clazz);
      for (int i = 0; i < projectionAttrs.length; i++)
      {
      projectionAttrs[i] = projectionAttrs[i].substring(projectionAttrs[i].indexOf('.') + 1);
      }
     
      ArrayList descs = cld.getAttributeDescriptorsForPath(projectionAttrs[0]);
      int pathLen = descs.size();
     
      if ((pathLen > 0) && (descs.get(pathLen - 1) instanceof ObjectReferenceDescriptor))
      {
      ObjectReferenceDescriptor ord =
      ((ObjectReferenceDescriptor) descs.get(pathLen - 1));
      query = QueryFactory.newQuery(clazz, criteria, distinct);
      query.setObjectProjectionAttribute(projectionAttrs[0],
      ord.getItemClass());
      }
      else
      {
      query = QueryFactory.newReportQuery(clazz, projectionAttrs, criteria, distinct);
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

            Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
            // join selection of elements with predicate criteria:
            pCrit.addAndCriteria(allElementsCriteria);
            Class clazz = this.getElementsExtentClass(broker);
            Query q = new QueryByCriteria(clazz, pCrit);
            if (log.isDebugEnabled()) log.debug(q.toString());
            // 2. perfom query
            return (DSetImpl) broker.getCollectionByQuery(DSetImpl.class, q);
        }
        catch (PersistenceBrokerException e)
        {
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

        {
            log.debug("Retrieving all products");
        }

        // 1. build a query that select all objects of Class Product, without any further criteria
        Query             query  = new QueryByCriteria(Product.class, null);
        PersistenceBroker broker = null;
        Collection        result = null;

        try
        {
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

          Map<Object, Object> row = new HashMap<Object, Object>();
          // TODO: optimize, just retrieve the id from the DB and setup
          // a JetspeedPrincipal template on that.
          rr.readObjectArrayFrom(rs, row);
          PersistentJetspeedPrincipal p = (PersistentJetspeedPrincipal) rr.readObjectFrom(row);
          QueryByCriteria query = new QueryByCriteria(p);
          p = (PersistentJetspeedPrincipal) PersistenceBrokerFactory.defaultPersistenceBroker()
              .getObjectByQuery(query);
          results.add(p);
          if (!rs.next()) {
            break;
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

    // JetspeedPermissionAccessManager interface implementation
    //
    @SuppressWarnings("unchecked")
    public List<PersistentJetspeedPermission> getPermissions()
    {
        QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, new Criteria());
        query.addOrderByAscending("type");
        query.addOrderByAscending("name");
        return (List<PersistentJetspeedPermission>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

        criteria.addEqualTo("type", type);
        if (nameFilter != null && nameFilter.length() > 0)
        {
            criteria.addLike("name", nameFilter+"%");
        }
        QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, criteria);
        query.addOrderByAscending("name");
        return (List<PersistentJetspeedPermission>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

    @SuppressWarnings("unchecked")
    public List<PersistentJetspeedPermission> getPermissions(PersistentJetspeedPrincipal principal)
    {
        Criteria criteria = new Criteria();
        criteria.addEqualTo("principals.principalId", principal.getId());
        QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPermissionImpl.class, criteria);
        query.addOrderByAscending("type");
        query.addOrderByAscending("name");
        return (List<PersistentJetspeedPermission>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

        if (principalType != null)
        {
            criteria.addEqualTo("type", principalType);
        }
        criteria.addEqualTo("domainId", getDefaultSecurityDomainId());
        QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class, criteria);
        query.addOrderByAscending("type");
        query.addOrderByAscending("name");
        return (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
    }
View Full Code Here

Examples of org.apache.ojb.broker.query.QueryByCriteria

        if (principalType != null)
        {
            criteria.addEqualTo("type", principalType);
        }
        criteria.addEqualTo("domainId", getDefaultSecurityDomainId());
        QueryByCriteria query = QueryFactory.newQuery(PersistentJetspeedPrincipal.class, criteria);
        List<JetspeedPrincipal> currentList = (List<JetspeedPrincipal>) getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query));
        List<JetspeedPrincipal> targetList = new ArrayList<JetspeedPrincipal>(principals);
        for (Iterator<JetspeedPrincipal> i = currentList.iterator(); i.hasNext(); )
        {
            JetspeedPrincipal current = i.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.