WebSphere Adapter for JDBC

Business object structure

The Adapter for JDBC supports table and view business objects. For applications that use databases, each business object corresponds to a database table or view, and each simple attribute within the object corresponds to a column in that table or view. In addition, the adapter supports stored procedure and query business objects.

For table or view business objects

A simple attribute is an attribute that represents a single value, such as a String, Integer, or Date. Thus, attributes within the same business object cannot be stored in different database tables; however, the following situations are possible:
  • The database table might have more columns than the corresponding business object has simple attributes; that is, some columns in the database are not represented in the business object. Only those columns needed for processing of the business object should be included in your design.
  • The business object might have more simple attributes than the corresponding database table has columns; that is, some attributes in the business object are not represented in the database. The attributes that do not have a representation in the database either have no application-specific information, are set with default values, or are specified by stored procedures.
  • The business object can represent a view that spans multiple database tables. The adapter can use such a business object when processing requests triggered in the application, such as Create, Update, and Delete operations. When processing business object requests, however, the adapter can use such a business object only for Retrieve and RetrieveAll requests.

For stored procedure business objects

In this case, business objects are generated for stored procedures. All of the stored procedure input and output parameters have corresponding attributes in the business object. If any of the input or output parameters is of a complex type, such as an array or struct, then the corresponding business object attribute is a child business object type with the child business object containing the attributes of the array or struct. If the stored procedure returns a result set, a child business object is created that contains the attributes of the returned result set.

Two examples are given below to show the structure of stored procedure business objects. The business objects, ScottStrtValues and ScottStrtvaluesStrt, are generated from a stored procedure that has one input type and two output types. One of the output parameters is of the struct data type. Enterprise metadata discovery generates a business object, ScottStrtValuesStrt, for the struct type and adds it as a child object to the parent business object, ScottStrtValues. For the attribute of type struct in the parent business object, the ChildBOType application-specific information is set to Struct to indicate it is of type struct. The ChildBOTypeName application-specific information is set to the value of the user-defined struct type in the database.

Example of ScottStrtValues business object

<?xml version="1.0" encoding="UTF-8" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvalues" xmlns:scottstrtvalues=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvalues" xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata" xmlns:scottstrtvaluesstrt=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvaluesstrt"> <import namespace=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvaluesstrt"
schemaLocation="ScottStrtvaluesStrt.xsd"/> <import namespace="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"
schemaLocation="JDBCASI.xsd"/> <annotation> <appinfo source="commonj.connector.asi"> <asi:annotationSet xmlns:asi="commonj.connector.asi" asiNSURI=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"/> </appinfo> </annotation> <complexType name="ScottStrtvalues"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCBusinessObjectTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPName>SCOTT.STRTVALUES</jdbcasi:SPName> <jdbcasi:MaxNumOfRetRS>0</jdbcasi:MaxNumOfRetRS> <jdbcasi:ResultSet>false</jdbcasi:ResultSet> </jdbcasi:JDBCBusinessObjectTypeMetadata> </appinfo> </annotation> <sequence minOccurs="1" maxOccurs="1"> <element name="pkey" type="int" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType>IP</jdbcasi:SPParameterType> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="fname" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType>OP</jdbcasi:SPParameterType> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="strt" type="scottstrtvaluesstrt:ScottStrtvaluesStrt"
minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType>OP</jdbcasi:SPParameterType> <jdbcasi:ChildBOType>STRUCT</jdbcasi:ChildBOType> <jdbcasi:ChildBOTypeName>STRUCT1</jdbcasi:ChildBOTypeName> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> </sequence> </complexType> </schema>

Example of ScottStrtValuesStrt business object

<?xml version="1.0" encoding="UTF-8" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvaluesstrt" xmlns:scottstrtvaluesstrt=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/scottstrtvaluesstrt" xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <import namespace="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"
schemaLocation="JDBCASI.xsd"/> <annotation> <appinfo source="commonj.connector.asi"> <asi:annotationSet xmlns:asi="commonj.connector.asi" asiNSURI=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"/> </appinfo> </annotation> <complexType name="ScottStrtvaluesStrt"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCBusinessObjectTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPName>SCOTT.STRTVALUES</jdbcasi:SPName> </jdbcasi:JDBCBusinessObjectTypeMetadata> </appinfo> </annotation> <sequence minOccurs="1" maxOccurs="1"> <element name="name" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType></jdbcasi:SPParameterType> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="title" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType></jdbcasi:SPParameterType> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="dept_num" type="int" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SPParameterType></jdbcasi:SPParameterType> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> </sequence> </complexType> </schema>

For query business objects

An example select statement is provided to show the structure of a query business object. For the following select statement:

SELECT C.custid, C.custname, A.phone FROM customer C, address A WHERE (C.custid = A.custid) AND (C.custname LIKE ?)

The query business object has the following format:

Business object level application-specific information as follows:

SelectStatement = SELECT C.custid, C.custname, A.phone FROM customer C, address A WHERE (C.custid = A.custid) AND (C.custname LIKE ?)

The attributes as follows:
  • custid ColumnName=CUSTID
  • custname ColumnName=CUSTNAME
  • phone ColumnName=PHONE
  • parameter1 (Corresponding to the one ?, should have as many parameters as there are ?s)
  • jdbcwhereclause

The operation supported: RetrieveAll

The following example shows a query business object definition file.

Example query business object
<?xml version="1.0" encoding="UTF-8" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/querybo1" xmlns:querybo1=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/querybo1" xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <import namespace="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"
schemaLocation="JDBCASI.xsd"/> <annotation> <appinfo source="commonj.connector.asi"> <asi:annotationSet xmlns:asi="commonj.connector.asi" asiNSURI=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"/> </appinfo> </annotation> <complexType name="QueryBO1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCBusinessObjectTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:SelectStatement>select * from customer where
pkey=?</jdbcasi:SelectStatement> </jdbcasi:JDBCBusinessObjectTypeMetadata> </appinfo> </annotation> <sequence minOccurs="1" maxOccurs="1"> <element name="pkey" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:ColumnName>PKEY</jdbcasi:ColumnName> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="fname" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:ColumnName>FNAME</jdbcasi:ColumnName> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="lname" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:ColumnName>LNAME</jdbcasi:ColumnName> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="ccode" type="string" minOccurs="0" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:ColumnName>CCODE</jdbcasi:ColumnName> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="parameter1" type="string" minOccurs="1" maxOccurs="1"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:ColumnName>Parameter1</jdbcasi:ColumnName> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> <element name="jdbcwhereclause" type="string" minOccurs="0" maxOccurs="1"
default="where pkey=?"> <annotation> <appinfo source="http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:JDBCAttributeTypeMetadata xmlns:jdbcasi=
"http://www.ibm.com/xmlns/prod/websphere/j2ca/jdbc/metadata"> <jdbcasi:PrimaryKey>false</jdbcasi:PrimaryKey> </jdbcasi:JDBCAttributeTypeMetadata> </appinfo> </annotation> </element> </sequence> </complexType> </schema>

For all business objects

Business objects can be either flat or hierarchical. All of the attributes of a flat business object are simple and represent one row in the database table. The term hierarchical business object refers to a complete business object, including all the child business objects that it contains at any level. The term individual business object refers to one business object, independent of child business objects that it might contain or that contain it. The individual business object can represent a view that spans multiple database tables. The term top-level business object refers to the individual business object at the top of the hierarchy that does not itself have a parent business object.

A hierarchical business object has attributes that represent a child business object, an array of child business objects, or a combination of the two. In turn, each child business object can contain a child business object or an array of business objects, and so on.

A single-cardinality relationship occurs when an attribute in a parent business object represents one child business object. In this case, the attribute is of the same type as the child business object.

A multiple-cardinality relationship occurs when an attribute in the parent business object represents an array of child business objects. In this case, the attribute is of the same type as the child business objects.

The adapter supports the following relationships among business objects:
  • Single-cardinality relationships
  • Single-cardinality relationships and data without ownership
  • Multiple-cardinality relationships

In each type of cardinality, the relationship between the parent and child business objects is described by the application-specific information of the key attribute in the business object storing the relationship. For more information on this application-specific information, see "ForeignKey" in the "Attribute application-specific information" table.


Terms of use |

Last updated: Tue 12 Dec 2006 03:32:38

(c) Copyright IBM Corporation 2005, 2006.
This information center is powered by Eclipse technology (http://www.eclipse.org)