Skip Headers
Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3.0)

Part Number B28967-02
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

19 Advanced TopLink Topics

This chapter describes how to use the advanced TopLink functions in the Mapping editor.

This chapter includes the following sections:

19.1 Introduction to Advanced TopLink Topics

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.

19.2 Using Advanced Parameters (databindings.cpx)

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.

Figure 19-1 TopLinkDefinition Properties Dialog

This image shows the TopLink Definition Properties dialog

19.2.1 Performing Deletes First

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.

Example 19-1 Specifying the TopLinkShouldPerformDeletesFirst Option

...
<Parameter
   name="TopLinkShouldPerformDeletesFirst"
   value="True"
</Parameter
...

19.2.2 Specifying the TopLink Session File

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.

Example 19-2 Specifying the TopLinkSessionsXMLFileName Option

...
<Parameter
   name="TopLinkSessionsXMLFileName"
   value="META-INF/sessions.xml"
</Parameter
...

19.2.3 Specifying the Sequencing

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

Example 19-3 Specifying the ToplinkSequenceOnCreate Option

...
<Parameter
   name="TopLinkSequenceOnCreate"
   value="False"
</Parameter
...

19.3 Configuring Method Access for Relationship

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:

  1. Select a relationship mapping from a TopLink descriptor in the Structure window.

  2. On the mapping's General tab, select the Use Method Accessing option.

    Figure 19-2 General Tab of TopLink Mapping Editor

    Image shows TopLink Mapping editor dialog
  3. Select the specific getter and setter methods for the relationship.

19.4 Using sessions.xml with a TopLink Data Control

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):

  1. Right-click the sessions.xml file in the Navigator window and select Create Data Control.

  2. On the TopLink Data Control dialog, select the TopLink Sessions Configuration option.

    Figure 19-3 Creating a TopLink Data Control (from a Sessions Configuration)

    image of creating a TopLink Data Control
  3. Select the specific sessions configuration file (or create a new configuration) and session. You can create a data control for any mapped classes.

19.5 Using Multiple Maps with a TopLink Data Control

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.

Figure 19-4 Create Object Relational Map Dialog

This figure shows the Create Object Relational Map dialog

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:

  1. Right-click the sessions.xml file in the Navigator window and select Create Data Control.

  2. On the TopLink Data Control dialog, select the TopLink Map option.

    Figure 19-5 Creating a TopLink Data Control (from a TopLink Map)

    Image shows TopLink Data Control page
  3. Select the specific TopLink map.

  4. Select the specific sessions configuration file (or create a new configuration) and session. You can create a data control for any mapped classes.

19.6 Compiling TopLink Classes with Specific JDK Versions

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.

Figure 19-6 Edit J2SE Definition Page

image of Edit J2SE Definition dialog with new JDK library