
Chapter 8 Creating J2EE Applications for BEA WebLogic
Defining a mapping for a Bean
PowerAMC supports simple O/R mapping and complex O/R mapping.
- Simple O/R mapping uses a one-to-one mapping. For example, a class maps to a table and an attribute maps to a column.
- Complex O/R mapping can map a class to several tables and an attribute to a query.
WebLogic Server can manage persistence of entity beans at the container level only in the case of simple O/R mapping (i.e. a class maps to only one table and a class attribute maps to only one table column).
The O/R mapping in the case of Enterprise Java Beans is specified in the Mapping tab of the Bean Class of the EJB Component. It is used to generate an O/R mapping descriptor (a XML file) for CMP EJBs in BEA WebLogic Server, or to generate BMP EJBs.
The Mapping tab describes where and how class instances are stored into the database (i.e. Data Source). A Data Source specifies the mappings for a class.
Once a Data Source is selected, the Mapping tab of the Bean class property sheet contains the following tabbed pages:
- Class Sources - composed of a list of source tables or views. It allows you to select a table or a view from Physical models specified in the data source.
WebLogic Server supports only one table for each bean class, so there can only be one table in this list.
- Attributes Mapping - Once a table is added in the Class Sources tabbed page, we can define a mapping for each attribute of the Bean Class and can map the attribute to a column of the selected table.
Specific case for Oracle BLOB or CLOB: For an Oracle database, if the mapped column is a BLOB or a CLOB, we need to specify a value in the dbms-column-type extended attribute of the class attribute. This value can be either Oracle BLOB or Oracle CLOB.
For more information on the dbms-column-type, see BLOB and CLOB DBMS Column Support for the Oracle DBMS.
- Operation Mapping - Operation mapping allows the user to associate a SQL query with a class operation for a Data Source. Usually this SQL query is a select statement used to retrieve an instance, or instances of the current class according to the operation parameters.
In the Enterprise Java Bean context, SQL queries attached to operations are used to implement finder or select methods.
In the case of WebLogic server, it is not required to specify a mapping for operations. But we can define the following extended attributes for finder or select methods (i.e PowerAMC Operations):
- weblogic-ql (Operation extended attribute) (see also Using EJB 2.0 WebLogic QL Extension for EJB QL)
- group-name (Operation extended attribute) (see Groups)
- max-elements (Operation extended attribute)
- include-updates (Operation extended attribute) (see Flushing the CMP Cache)
- Criteria - Additional criteria can be specified for the class mapping in order to define conditions for selecting, updating or deleting class instances using SQL queries.
Note: This criteria is not used for WebLogic.
- Select – The SQL select statement is used to retrieve attribute values of a class instance from the database using its identifying attributes.
Note: This statement is not used for WebLogic.
- Insert – The SQL insert statement is used to create an instance of the class and saved all of its attributes
Note: This statement is not used for WebLogic.
- Update – The SQL update statement is used to update attribute values of a class instance (note: you cannot update values of identifying attributes)
Note: This statement is not used for WebLogic.
- Delete – The SQL delete statement is used to delete a class instance in the database using its identifying attributes.
Note: This statement is not used for WebLogic.
Copyright (C) 2005. Sybase Inc. All rights reserved.
|
|