Use the EJB data mediator service for data access
The following steps use code samples to describe a simple instance of how to create the EJBs data mediator service (DMS) metadata.
- A mediator instance is created using one of the create methods on the mediator factory (com.ibm.websphere.sdo.mediator.ejb.MediatorFactory) as in the following example
import com.ibm.websphere.sdo.mediator.ejb.Mediator; import com.ibm.websphere.sdo.mediator.ejb.MediatorFactory; import com.ibm.webpshere.ejbquery.QueryException; import commonj.sdo.DataObject; try{String[] query = { "select d.deptno,d.name from DeptBean as d" };
Mediator m = MediatorFactory.getInstance().createMediator( query, null);
DataObject root = m.getGraph(); } catch (QueryException e) { ... }
- There are 3 different forms of the createMediator method. The arguments are explained as follows:
createMediator( query, parms) createMediator( query, parms, schema ) createMediator( query, parms, schema, typeMap, pattern)
Table 1. createMediator method arguments
String query array of EJB query statements Object parms values for input parameters of the query statements Eclass* schema the EClass of the root DataObject Map* typeMap a java.util.Map that maps EJB Abstract Schema Names from the query statement into Eclass names int* pattern the pattern used for containment * used only when using caller provided schema
Enterprise Java Beans Data Mediator Service
Related
DataGraph schema
Example: Using query arguments with EJB mediator