Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Working With the ejb-jar.xml File

For TopLink Workbench relational projects that use EJB 2.0 CMP persistence, use the ejb-jar.xml file to store persistence information for the application server. With TopLink Workbench, you can import information from an existing ejb-jar.xml file into your project, or you can create and update the ejb-jar.xml file from your project.

Each TopLink Workbench project uses a single ejb-jar.xml file. For each entity bean in the file, you should have an EJB descriptor in the project. All entity beans must use the same persistence type.

As you make changes in your project, you can update the ejb-jar.xml file to reflect your project. Additionally, if you edit the ejb-jar.xml file outside TopLink Workbench, you can update your project to reflect the current file.

Table 21-2 describes how fields in the ejb-jar.xml file correspond to specific functions in TopLink Workbench.

Table 21-2 ejb-jar.xml Fields and TopLink Workbench

ejb-jar.xml Fields TopLink Workbench

primkey

Bean attribute mapped to the primary key in the database table (see "Configuring Primary Keys").

ejb-name, prim-key-class, local, local-home, remote, home, and ejb-class

EJB descriptor information on the EJB Info tab (see "Configuring a Descriptor With EJB Information").

abstract-schema-name

Descriptor Alias field (see "Configuring Descriptor Alias").

cmp-field

Direct (non-relationship) attributes on the Descriptor Info tab (see "Configuring Common Descriptor Options").

cmp-version

Persistence Type field on the General tab (see "Configuring Persistence Type"). The persistence-type is set to container.

query

Queries listed in Queries tab (see "Configuring Named Queries at the Descriptor Level").

Note: The findByPrimaryKey query is not in the ejb-jar.xml file as per the EJB 2.0 specification.

relationships

One-to-one, one-to-many, and many-to-many mappings (see Part XI, "Relational Mappings").


Writing to the ejb-jar.xml File

To update the ejb-jar.xml file based on the current TopLink Workbench information, use this procedure. Use the EJB preferences to specify whether or not TopLink Workbench automatically updates the ejb-jar.xml file when you save the project.


Note:

You can also write the information to a .jar file. TopLink Workbench automatically places the ejb-jar.xml file in the proper location (META-INF/ejb-jar.xml).

  1. Choose Selected > Write Project to ejb-jar.xml from the menu.

    You can also right-click the project in the Navigator and choose Write Project to ejb-jar.xml from the context menu.

    • If the project does not currently contain an ejb-jar.xml file, the system prompts you to create a new file.

    • If the system detects that changes were made to the ejb-jar.xml file but not yet read into TopLink Workbench (for example, you changed the file outside TopLink Workbench), then the system prompts you to read the file before writing the changes.

Reading From the ejb-jar.xml File

To read the ejb-jar.xml information and update your TopLink Workbench project, use this procedure.


Tip:

To automatically create EJB descriptors in TopLink Workbench for all entities, read the ejb-jar.xml file before adding any classes in TopLink Workbench.

  1. Choose Selected > Update Project from ejb-jar.xml from the menu.

    You can also right-click the project in the Navigator window and choose Update Project from ejb-jar.xml from the context menu.


Note:

If you are using TopLink Workbench behind a firewall, before reading from the ejb-jar.xml file, you may need to configure TopLink Workbench with a proxy (see "Help Preferences"). If TopLink Workbench fails to read the ejb-jar.xml file due to connection timeout or no route to host, proxy configuration is required.