Skip Headers
Oracle Fusion Middleware Developer's Guide for Oracle TopLink
11g Release 1 (11.1.1)

Part Number B32441-02
Go to Documentation Home
Home
Go to Book List
Book List
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

7 Using an Integrated Development Environment

This chapter includes information on using TopLink with an integrated development environment (IDE).

This chapter includes the following sections:

In addition to the development environment described here, TopLink can be used with any Java EE development environment and process.

7.1 Configuring TopLink for Oracle JDeveloper

This section contains information on how to configure TopLink for use with Oracle JDeveloper. Oracle JDeveloper is a Java EE development environment with end-to-end support to develop, debug, and deploy e-business applications and Web services.

7.1.1 How to Use TopLink Mappings

Starting with Oracle JDeveloper 10g, the standard Oracle JDeveloper installation includes an embedded TopLink editor. Refer to the Oracle JDeveloper documentation for complete information.

To use TopLink with Oracle JDeveloper 9.0.4 (and earlier), use the following procedure to add the TopLink JAR files to your Oracle JDeveloper projects:

  1. Select a Oracle JDeveloper project in the System Navigator window.

  2. Choose Project > Project Settings. The Project Settings window appears.

  3. Choose Configurations > Development > Libraries. A list of predefined and user-defined libraries appears.

    Figure 7-1 List of Available Libraries

    Description of Figure 7-1 follows
    Description of "Figure 7-1 List of Available Libraries"

  4. Click New to create a new library that will contain the TopLink .jar files. The New Library dialog box appears.

  5. Enter a name for the new library–for example, TopLink. Ensure that the default choice for Location remains as User Libraries.

    Figure 7-2 Creating a New Library Dialog Box

    Description of Figure 7-2 follows
    Description of "Figure 7-2 Creating a New Library Dialog Box"

  6. To edit the Class Path and add the TopLink .jar files, click Edit.

    Add the following to the beginning of your Class Path:

    <TOPLINK_HOME>\jlib\toplink.jar
    <TOPLINK_HOME>\modules\com.bea.core.antlr.runtime_2.7.7.jar
    <ORACLE_HOME>\modules\xmlparserv2.jar
    <ORACLE_HOME>\modules\xml.jar
    
  7. Click OK. On the Project Settings window click OK.

Using an Existing User-Defined TopLink Library

After a user library is created, it can be referenced again by any other project. Revisit the Libraries window of the Project Settings, and add the TopLink Library to any project with which you want to use TopLink.

7.2 Configuring TopLink Workbench with Source Control Management Software

You can use TopLink Workbench with a source control management (SCM) system to facilitate enterprise-level team development (see Section 7.2.1, "How to Use a Source Control Management System"). If you have a small development team, you can manage the changes from within XML files (see Section 7.2.3, "How to Share Project Objects").

When using a TopLink Workbench project in a team environment, you must synchronize your changes with other developers. See Section 7.2.2, "How to Merge Files" for more information.

7.2.1 How to Use a Source Control Management System

If you use an enterprise, file-based source control management system to manage your Java source files, you can use the same system with your TopLink Workbench project files. These project files are maintained by TopLink Workbench and written out in XML file format.

The check in and check out mechanism for the source control system defines how to manage the source (the XML source and TopLink Workbench project file) in a multiuser environment.

Checking Out and Checking In TopLink Workbench Project Files

Although your actual development process will vary depending on your SCM tool, a typical process involves the following steps:

  1. Determine (based on your SCM system) which files to retrieve from the source management system.

  2. Edit the project using TopLink Workbench.

  3. Save the edited project. If TopLink Workbench displays the Read-Only Files dialog box, make a note of these files, they must be unlocked and possibly merged. See Section 7.2.5, "How to Work with Locked Files" for more information.

  4. Merge the required project files. See Section 7.2.2, "How to Merge Files" for details.

  5. Check in the modified files, then retrieve from the repository any files that have been added or modified for this TopLink Workbench project.

7.2.2 How to Merge Files

The most difficult aspect of application development is merging changes from two (or more) development team members that have simultaneously edited the same file. If you check in your changes, a merge condition exists. Use a file comparison tool to determine the merged aspects of the project. The files to edit will vary, depending on the type of merge, as follows:

Example 7-1 and Example 7-2 demonstrate a merge out merging technique.

7.2.2.1 Merging Project Files

Project files contain references to the objects in the project. Generally, your project <projectName>.mwp contains the following elements:

  • Database information: <database>

    • Database tables: <tables>

  • Descriptors: <descriptors>

  • Repository: <repository>

    • Classes: <classpath-entries>

Changes in these parts of the .mwp file are usually caused by adding, deleting, or renaming project elements.

To merge project files, you will generally need to merge a project file if another developer has added or removed a descriptor, table, or class, and checked in the project while you were adding or removing descriptors, tables, or classes from the same project. To merge the project's .mwp file, use this procedure:

  1. Perform a file comparison between the <projectName>.mwp file in the repository and your local copy. The file comparison shows the addition or removal of a project element inside the owner (that is, <database>, <descriptors>, or <repository>).

  2. Insert the XML script to, or delete from your local <projectName>.mwp file (inside the corresponding owner element). This brings your local code up-to-date to the current code in the code repository.

  3. Retrieve any updated files, as indicated by your source control system.

Your local source now matches the repository.

Example 7-1 Merging Projects

Another developer has added and checked in a new Employee class descriptor to the com.demo package while you were working with the same TopLink Workbench project. To merge your work with the newly changed project, follow these steps:

  1. Perform a file comparison on the <projectName>.mwp file to determine the differences between your local file and the file in the repository. Your SCM system may show the file in merge status.

    The file comparison shows the addition of the <package-descriptor> tag and a <name> element inside that tag:

    <package-descriptor>
        <name>com.demo.Employee.ClassDescriptor</name>
    </package-descriptor>
    
  2. Insert this XML into your <projectName>.mwp file (inside the <descriptors> element) to bring it up-to-date with the current files in the source repository.

  3. Retrieve any new or updated files from your source control system. This includes the newly added Employee class descriptor.

  4. Check in files that you have modified.

7.2.2.2 Merging Table, Descriptor, and Class Files

Developers who concurrently modify the same existing table, descriptor, or class file will create a merge condition for the following files:

  • Table: <tableName>.xml (one for each table)

  • Descriptor: <descriptorName.type>.xml (one for each descriptor)

  • Class: <className>.xml (one for each class)

TopLink Workbench changes these files when saving a project if you have changed any of the contents within them (such as adding a mapping to a descriptor, adding an attribute to a class, or a changing a field reference in a table).

If another developer has changed an attribute in a table, descriptor, or class, while you were changing a different mapping on that same descriptor, you will need to merge your project. To merge your project, use this procedure:

  1. Perform a file comparison on the specific .xml files in merge status (that is, table, descriptor, or class). The file comparison shows the addition or removal of an XML element.

  2. Insert the XML script to, or remove from your local .xml file to bring it up-to-date with the current files in the source repository.

Example 7-2 Merging Files

Another developer has added and checked in the firstName mapping to the Employee class descriptor while you were changing a different mapping on that same descriptor. To merge your work with the newly changed project, use this procedure:

  1. Perform a file comparison on the com.demo.Employee.ClassDescriptor.xml file located in <projectRoot>/Descriptor/ directory that is in merge status.

    The file comparison shows the addition of the <mapping> tag and the elements inside that tag:

    <mapping>
        <uses-method-accessing>false</uses-method-accessing>
        <inherited>false</inherited>
        <read-only>false</read-only>
        <instance-variable-name>firstName</instance-variable-name>
        <default-field-names>
            <default-field-name>direct field=</default-field-name>
        </default-field-names>
        <field-handle>
            <field-handle>
                <table>EMPLOYEE</table>
                <field-name>F_NAME</field-name>
            </field-handle>
        </field-handle>
    <mapping-class>MWDirectToFieldMapping </mapping-class>
    </mapping>
    
  2. Insert this XML block into your local com.demo.Employee.ClassDescriptor.xml file (inside the existing <mapping> element) to bring it up to date to the current files in the source repository.

  3. Retrieve any new files noted as missing by your source control system. This includes any tables or descriptors that may be referenced by the new mapping.

  4. Check in files that you have modified.

7.2.3 How to Share Project Objects

You can also share project objects by copying the table or descriptor files into the appropriate directories in the target project.

After copying the files, insert a reference to the table, descriptor, or class in the appropriate place in the <projectName>.mwp file. All references contained within the project file must refer to an existing object in the project.

7.2.4 How to Manage the ejb-jar.xml File

When working in a team environment, manage the ejb-jar.xml file similarly to the .xml project files. TopLink Workbench edits and updates the ejb-jar.xml file, if necessary, when working with an EJB project.

If you use a version control system, perform the same check in and check out procedures. For merge conditions, use a file comparison tool to determine which elements have been added or removed. Modify the file as necessary and check in the file to exercise version control on your work.

7.2.5 How to Work with Locked Files

When working in a team environment, your source control system may lock files when you retrieve them from the repository. If TopLink Workbench attempts to save a locked file, the Version Control Assistance dialog box appears, showing the locked files.

Figure 7-3 Version Control Assistance Dialog Box

Description of Figure 7-3 follows
Description of "Figure 7-3 Version Control Assistance Dialog Box"

Select one of the following methods to save your project:

  • Use your source control system to unlock the files, and then click Save.

  • Click Save As to save the project to a new location.

See Section 116.2.2, "How to Save Projects" for more information.