DataGraph schema

 

DataGraph schema created by the EJB mediator

If

no ECLass argument is used on createMediator, then the mediator creates a DataGraph schema with the following characteristics:

  • the DataObject Eclass names are the corresponding Enterprise JavaBeans (EJB) Abstract Schema Names (ASN)

  • the DataObject attributes names and types are the expression names and types in the query SELECT clauses

  • the DataObject reference names and types come from the EJB relationships referenced in the FROM clauses.

A “dummy” DataObject with the Eclass name of DataGraphRoot is also created and has containment reference to all the DataObjects. The reference is multivalued, using the EJB ASN name.

DataObject root =  m.getGraph( parms );
root.getType().getName();   // this would return the string "DataGraphRoot"

List depts = (List) root.get("DeptBean");   
// the list of all DeptBean SDOs in the DataGraph

List emps = (List) root.get("EmpBean");  
// the list of all EmpBean SDOs in the DataGraph

 

DataGraph schema defined by the caller

The caller can create the DataGraph either using Eclipse Modeling Framework (EMF) APIs to programmatically create the schema dynamically, or by generating static Java classes from an EMF model. In either case the Eclass of the root DataObject must be passed to the mediator. If the DataGraph pattern includes a “dummy” root, then this root must be part of the user supplied schema and the Eclass of the root is passed on the create call.

A user created schema can contain additional attributes and references that are not set by the mediator when constructing DataObjects. However, if any attribute or reference required by the mediator query does not exist or has an inconsistent type, an exception occurs.

The Eclass names used in this schema are by default the EJB ASN names. We can override this by passing to the mediator a java.util.Map argument.

 

DataGraph containment patterns

References between Service Data Objects (SDO) can be defined as containment references, in which case when an SDO is deleted the delete is cascaded to all of the contained SDO. Also, when the DataGraph is serialized as an XML document, the contained SDO are nested within the parent SDO. Noncontained references are expressed as path expressions in the XML document.

Containment must be defined in the DataGraph schema. When the mediator defines the schema, the root SDO ( named DataGraphRoot) contains all other SDO. EJB relationships are defined as noncontained SDO references.

When the caller defines the DataGraph schema, there are three patterns.

ROOT_CONTAINS_ALL

This is the same as above. There must still be a dummy root SDO that contains all other SDO, except the Eclass name of the root can be any valid name (it does not have to be DataGraphRoot), and the reference names on the root can be any name.

ROOT_CONTAINS_SOME

There must be a dummy root SDO. An EJB relationship referenced in the query can be defined as an SDO contained reference. If not, then the dummy root MUST be defined to contain the SDO.

NO_DUMMY ROOT

There is no dummy root SDO. The DataGraph root refers to the SDO returned by the first mediator query statement. Because a DataGraph can have only one root instance, if the query returns zero or more than one record, an exception occurs.