Oracle® Application Development Framework Developer's Guide 10g Release 3 (10.1.3.0) Part Number B28967-02 |
|
|
View PDF |
This chapter describes how to use the advanced TopLink functions in the Mapping editor.
This chapter includes the following sections:
Section 19.2, "Using Advanced Parameters (databindings.cpx)"
Section 19.4, "Using sessions.xml with a TopLink Data Control"
Section 19.5, "Using Multiple Maps with a TopLink Data Control"
Section 19.6, "Compiling TopLink Classes with Specific JDK Versions"
The TopLink mappings (introduced in Chapter 3, "Building and Using Application Services") allow you to map Java objects to your database. When creating TopLink mappings, there are some functions that are not available from the Mapping editor. You will need to implement these functions in your Java code. Refer to the Oracle TopLink Developer's Guide for additional information.
You can use the databindings.cpx
file to override or modify the default TopLink data control behavior. This section includes information on the following options:
Refer to Appendix A, "Reference ADF XML Files" for additional information on parameters in the databindings.cpx
file.
Use the TopLinkDefinitions Properties dialog (see Figure 19-1) define these parameters on the data control.
By default, the TopLink unit of work (see Section 3.8, "Creating and Modifying Objects with a Unit of Work") performs insert operations before delete operations. However, there may be instances in which you must perform the delete operation first.
For example, removing a row with a primary key of 1 and then creating a new row with the same primary key within the same transaction will result in a SQL exception indicating that the row already exists.
To eliminate this problem, use the TopLinkShouldPerformDeletesFirst parameter in the databindings.cpx
file to force the unit of work to perform the delete operation first.
By default, the TopLink session configuration file is named sessions.xml
. You can create this file by using the Mapping editor in Oracle JDeveloper (refer to the Oracle JDeveloper online help for more information).
To specify a different sessions configuration file, use the TopLinkSessionsXMLFileName parameter in the databindings.cpx
file.
By default, the TopLink unit of work (see Section 3.8, "Creating and Modifying Objects with a Unit of Work") assigns sequence numbers during the commit operation. However, there may be instances in which the sequence number must be displayed in the user interface before the commit operation.
For example, if the sequence number is used as the value of an ID field in a form displayed to the user, you must have the sequence number before committing the transaction.
To eliminate this problem, use the TopLinkSequenceOnCreate parameter in the databindings.cpx
file to disable the assigning of the sequence number during the commit operation of a create transaction
By default, TopLink mappings use direct access to access public attributes. Alternatively, you can use getter and setter methods to access object attributes when writing the attributes of the object to the database, or reading the attributes of the object from the database. This is known as method access.
Figure 19-2 shows a TopLink mapped attribute that uses method accessing.
To configure method accessing for a relationship:
Select a relationship mapping from a TopLink descriptor in the Structure window.
On the mapping's General tab, select the Use Method Accessing option.
Select the specific getter and setter methods for the relationship.
You can create a data control from a TopLink sessions configuration file (sessions.xml
), similarly to creating a data control from a TopLink map (see Section 19.5, "Using Multiple Maps with a TopLink Data Control").
Use the TopLink Data Control dialog (as shown in Figure 19-3), select TopLink Sessions Configuration, and then select the specific sessions configuration file (sessions.xml
) and session.
To create a TopLink data control from a sessions configuration file (sessions.xml):
Right-click the sessions.xml
file in the Navigator window and select Create Data Control.
On the TopLink Data Control dialog, select the TopLink Sessions Configuration option.
Select the specific sessions configuration file (or create a new configuration) and session. You can create a data control for any mapped classes.
You can create multiple TopLink maps for use with each project. Each map can be associated with a specific database and connection, as shown inFigure 19-4.
You can create a data control from a TopLink map, similarly to creating a data control from a sessions.xml
file (see Section 19.4, "Using sessions.xml with a TopLink Data Control").
Use the TopLink Data Control dialog (as shown in Figure 19-5), select TopLink Map, and then select the specific map.
To create a TopLink data control from a TopLink map:
Right-click the sessions.xml
file in the Navigator window and select Create Data Control.
On the TopLink Data Control dialog, select the TopLink Map option.
Select the specific TopLink map.
Select the specific sessions configuration file (or create a new configuration) and session. You can create a data control for any mapped classes.
By default, when compiling TopLink classes, JDeveloper uses JDK 1.5 generic collection types for relationships. This will causes errors if you compile your project using a different JDK version (such as 1.4).
Before generating TopLink mappings you must change the default JSEE library for your project. In the Default Project Properties Dialog – Libraries page, click Change to select a new J2SE definition for the project. On the Manage Libraries Dialog – Edit J2SE Definitions Page (see Figure 19-6), select a (or create a new) J2SE definition to use.