Selecting Objects has been edited by Andrus Adamchik (Apr 17, 2008).

(View changes)

Content:

If a stored procedure is known to return at least one result set, procedure queries can be executed just like normal select queries. Of course in addition to returning data, such procedures can perform any other database operations.

Below is an example of creating a ProcedureQuery, initializing its parameters, and processing execution results.

DataContext ctxt;

// "my_procedure" is a name of a stored procedure,
// that must exist in the DataMap
ProcedureQuery query = new ProcedureQuery("my_procedure", Artist.class);

// Set "IN" parameter values
query.addParam("paramter1", "abc");
query.addParam("parameter2", new Integer(3000));

// run query as a normal select query
List objects = ctxt.performQuery(query);

// process results
Iterator it = objects.iterator();
while(it.hasNext()) {
  Artist artist = (Artist) it.next();
  ....
}

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences