Package org.apache.ojb.broker.query

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


* @since 04.07.2004
*/
public class PersistenceBrokerClinic extends PersistenceBrokerDaoSupport implements Clinic {

  public Collection getVets() throws DataAccessException {
    QueryByCriteria query = new QueryByCriteria(Vet.class);
    query.addOrderByAscending("lastName");
    query.addOrderByAscending("firstName");
    return getPersistenceBrokerTemplate().getCollectionByQuery(query);
  }
View Full Code Here


    query.addOrderByAscending("firstName");
    return getPersistenceBrokerTemplate().getCollectionByQuery(query);
  }

  public Collection getPetTypes() throws DataAccessException {
    QueryByCriteria query = new QueryByCriteria(PetType.class);
    query.addOrderByAscending("name");
    return getPersistenceBrokerTemplate().getCollectionByQuery(query);
  }
View Full Code Here

  }

  public Collection findOwners(String lastName) throws DataAccessException {
    Criteria criteria = new Criteria();
    criteria.addLike("lastName", lastName + "%");
    Query query = new QueryByCriteria(Owner.class, criteria);
    return getPersistenceBrokerTemplate().getCollectionByQuery(query);
  }
View Full Code Here

  }

  public void testGetObjectByQuery() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    pb.getObjectByQuery(query);
    pbControl.setReturnValue("", 1);
    pb.close();
    pbControl.setReturnValue(true, 1);
    pbControl.replay();
View Full Code Here

  }

  public void testGetCollectionByQuery() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    Collection result = new HashSet();
    pb.getCollectionByQuery(query);
    pbControl.setReturnValue(result, 1);
    pb.close();
    pbControl.setReturnValue(true, 1);
View Full Code Here

  }

  public void testGetIteratorByQuery() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    Iterator result = new HashSet().iterator();
    pb.getIteratorByQuery(query);
    pbControl.setReturnValue(result, 1);
    pb.close();
    pbControl.setReturnValue(true, 1);
View Full Code Here

  }

  public void testGetReportQueryIteratorByQuery() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    Iterator result = new HashSet().iterator();
    pb.getReportQueryIteratorByQuery(query);
    pbControl.setReturnValue(result, 1);
    pb.close();
    pbControl.setReturnValue(true, 1);
View Full Code Here

  }

  public void testGetCount() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    pb.getCount(query);
    pbControl.setReturnValue(0, 1);
    pb.close();
    pbControl.setReturnValue(true, 1);
    pbControl.replay();
View Full Code Here

  }

  public void testDeleteByQuery() {
    MockControl pbControl = MockControl.createControl(PersistenceBroker.class);
    final PersistenceBroker pb = (PersistenceBroker) pbControl.getMock();
    Query query = new QueryByCriteria(TestBean.class);
    pb.deleteByQuery(query);
    pbControl.setVoidCallable(1);
    pb.close();
    pbControl.setReturnValue(true, 1);
    pbControl.replay();
View Full Code Here

    {
        System.out.println("The list of available products:");

        // 1. build a query that select all objects of Class Product, without any further criteria
        // according to ODMG the Collection containing all instances of a persistent class is called "Extent"
        Query query = new QueryByCriteria(Product.class, null);

        try
        {
            // 2. ask the broker to retrieve the Extent collection
            Collection allProducts = broker.getCollectionByQuery(query);
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.query.QueryByCriteria

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.