Object Queries

To retrieve data from a local database, use one of the static Object Query methods in the MBO class.

Object Query methods are generated based on the object queries defined by the modeler in Unwired WorkSpace. Object Query methods carry query names, parameters, and return types defined in Unwired WorkSpace. Object Query methods return either an object, or a collection of objects that match the specified search criteria.

The following examples demonstrate how to use the Object Query methods of the Customer MBO to retrieve data.

This method retrieves all customers:

public static com.sybase.collections.GenericList<Customer> findAll()

com.sybase.collections.GenericList<Customer> customers = findAll();

This method retrieves all customers in a certain page:

public static com.sybase.collections.GenericList<Customer> findAll(int skip, int take)

com.sybase.collections.GenericList<Customer> customers = Customer.findAll(10, 5); 

Suppose the modeler defined the following Object Query for the Customer MBO in Sybase Unwired Workspace:

The preceding Object Query results in this generated method:

public static com.sybase.collections.GenericList<Customer> findByFirstName(String firstName)

com.sybase.collections.GenericList<Customer> customers = Customer.findByFirstName("fname");