com.ibm.websphere.sdo.mediator.ejb

Interface Mediator



  • public interface Mediator
    Used to retrieve a DataGraph and persists changes for an EJB schema. The mediator takes as input a request in the form of EJB queries and returns a DataGraph containing values derived from EJB cmp fields and EJB relationships.

    The mediator can retrieve data either from EJB instances cached in the container or the query request can be compiled into SQL and executed directly against the datasource. A DataGraph containing deferred updates can be persisted by the mediator by either compiling into SQL updates which are applied to the datasource or by making updates against EJB instances using the EJB local interface accessor methods and the local home. The local home must contain the methods

     findByPrimaryKey( ) 
     remove (Object)
     create ( ) 
     
    and the EJB local interface must have the EJB accessor methods. If this is not the case, then a MediatorAdapter can be used to provide a java class which will invoke other appropriate methods.

    Update processing is independent on how the DataGraph was originally retrieved. In other words it is possible to retrieve a DataGraph directly from the datasource but have the deferred updates applied through EJB's and vice versa.

    applyChanges does not have to be invoked on the same mediator instance used to obtain the DataGraph. However both instances must have been created with the same or equivalent EJB query and graph schema.

    Mediator methods be called in the context of either a user transaction or a container transaction.

    Exceptions thrown by applyChanges may put the transaction in MUST_ROLLBACK mode and the application must ensure that a rollback occurs. This prevents any partial updates from being committed to the datastore.

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void applyChanges(commonj.sdo.DataObject dg)
      Process the graph's change log into sql updates against the datasource based on the EJB O-R mapping.
      void applyChanges(commonj.sdo.DataObject dg, MediatorAdapter adapter)
      Process the graph's change log through EJB instance methods.
      commonj.sdo.DataObject getGraph()
      Executes the EJB queries and returns the DataGraph.
      commonj.sdo.DataObject getGraph(java.lang.Object[] parms)
      Executes the EJB queries and returns the DataGraph.
      org.eclipse.emf.ecore.EClass getSchema()
      Returns the schema for the datagraph as the EClass of the root DataObject.
    • Method Detail

      • getSchema

        org.eclipse.emf.ecore.EClass getSchema()
                                               throws QueryException
        Returns the schema for the datagraph as the EClass of the root DataObject.
        Returns:
        EClass of the root DataObject.
        Throws:
        QueryException - Message text contains details.
      • applyChanges

        void applyChanges(commonj.sdo.DataObject dg)
                          throws QueryException
        Process the graph's change log into sql updates against the datasource based on the EJB O-R mapping.
        Parameters:
        dg - A graph DataObject, usually the root DataObject.
        Throws:
        QueryException - The message text contains details. Typically an optimistic update collision was detected, an attempt to update a read only DataObject or some other runtime error. Transaction may be placed into MUST_ROLLBACK state if partial updates have been applied to datasource. Caller must ensure that transaction is rolled back.
      • applyChanges

        void applyChanges(commonj.sdo.DataObject dg,
                        MediatorAdapter adapter)
                          throws QueryException
        Process the graph's change log through EJB instance methods. The mediator uses the EJB local home interface to find, create or remove the EJB instance and EJB local interface accessor methods to update cmp fields and EJB relationships. An optional MediatorAdapter can be specified to customize processing.
        Parameters:
        dg - A graph DataObject, usually the root DataObject.
        adapter - A user class that provides customized handling of log changes.
        Throws:
        QueryException - The message text contains details. Typically an optimistic update collision was detected, an attempt to update a read only DataObject or some other runtime error. Transaction may be placed into MUST_ROLLBACK state if partial updates have been applied to datasource. Caller must ensure that transaction is rolled back.
      • getGraph

        commonj.sdo.DataObject getGraph()
                                        throws QueryException
        Executes the EJB queries and returns the DataGraph.
        Returns:
        The root DataObject of the graph.
        Throws:
        QueryException - The message text contains details. A runtime error in the server or datasource.
      • getGraph

        commonj.sdo.DataObject getGraph(java.lang.Object[] parms)
                                        throws QueryException
        Executes the EJB queries and returns the DataGraph. The parms argument are the values for the query input arguments.
        Parameters:
        parms - Values for the query input arguments. By convention ?1 refers to parms[0].
        Returns:
        The root DataObject of the graph.
        Throws:
        QueryException - The message text contains details. Possibly a runtime error in the server or datasource or invalid parms.
IBM WebSphere Application ServerTM
Release 9.0