IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Queries on BPEL process and task data > Business Process Choreographer EJB query API > Examples of the query and queryAll methods
Example: Including query properties in a query
This example shows how to use the query method to retrieve tasks that belong to a BPEL process. The process has query properties defined for it to include in the search.
For example, you want to search for all of the human tasks in the ready state that belong to a BPEL process. The process has a query property, customerID, with the value CID_12345, and a namespace. The following code snippet shows the query method call for the query:
query ( " DISTINCT TASK.TKIID, TASK_TEMPL.NAME, TASK.STATE, PROCESS_INSTANCE.NAME", " QUERY_PROPERTY.NAME = 'customerID' AND " + " QUERY_PROPERTY.STRING_VALUE = 'CID_12345' AND " + " QUERY_PROPERTY.NAMESPACE = 'http://www.ibm.com/xmlns/prod/websphere/mqwf/bpel/' AND " + " TASK.KIND IN ( TASK.KIND.KIND_HUMAN, TASK.KIND.KIND_PARTICIPATING ) AND " + " TASK.STATE = TASK.STATE.STATE_READY ", (String)null, (String)null, (Integer)null, (TimeZone)null );If you now want to add a second query property to the query, for example, Priority, with a given namespace, the query method call for the query looks as follows:
query ( " DISTINCT TASK.TKIID, TASK_TEMPL.NAME, TASK.STATE, PROCESS_INSTANCE.NAME", " QUERY_PROPERTY1.NAME = 'customerID' AND " + " QUERY_PROPERTY1.STRING_VALUE = 'CID_12345' AND " + " QUERY_PROPERTY1.NAMESPACE = 'http://www.ibm.com/xmlns/prod/websphere/mqwf/bpel/' AND " + " QUERY_PROPERTY2.NAME = 'Priority' AND " + " QUERY_PROPERTY2.NAMESPACE = 'http://www.ibm.com/xmlns/prod/websphere/mqwf/bpel/' AND " + " TASK.KIND IN ( TASK.KIND.KIND_HUMAN, TASK.KIND.KIND_PARTICIPATING ) AND " + " TASK.STATE = TASK.STATE.STATE_READY ", (String)null, (String)null, (Integer)null, (TimeZone)null );If you add more than one query property to the query, you must number each of the properties that you add as shown in the code snippet. However, querying custom properties affects performance; performance decreases with the number of custom properties in the query.