A script-enabled browser is required for this page to function properly.
Oracle Help for the WebContentsIndexSearchGlossaryView Topic


Advanced TopLink Topics

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

This chapter includes the following sections:

Introduction to Advanced TopLink Topics

The TopLink mappings (introduced in 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.

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 Reference ADF XML Files for additional information on parameters in the databindings.cpx file.

Use the TopLinkDefinitions Properties dialog (see Figure: TopLinkDefinition Properties Dialog) define these parameters on the data control.

TopLinkDefinition Properties Dialog

This image shows the TopLink Definition Properties dialog

Performing Deletes First

By default, the TopLink unit of work (see 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.

Specifying the TopLinkShouldPerformDeletesFirst Option

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

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.

Specifying the TopLinkSessionsXMLFileName Option

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

Specifying the Sequencing

By default, the TopLink unit of work (see 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

Specifying the ToplinkSequenceOnCreate Option

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

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: General Tab of TopLink Mapping Editor 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.

    General Tab of TopLink Mapping Editor

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

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 Using Multiple Maps with a TopLink Data Control).

Use the TopLink Data Control dialog (as shown in Figure: Creating a TopLink Data Control (from a Sessions Configuration)), 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.

    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.

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: Create Object Relational Map Dialog.

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 Using sessions.xml with a TopLink Data Control).

Use the TopLink Data Control dialog (as shown in Figure: Creating a TopLink Data Control (from a TopLink Map)), 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.

    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.

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: Edit J2SE Definition Page), select a (or create a new) J2SE definition to use.

Edit J2SE Definition Page

image of Edit J2SE Definition dialog with new JDK library