116.1.1 How to Create a Project Using Oracle JDeveloper

When you create a TopLink project using Oracle JDeveloper, your mapping information is stored in the TopLink map. The TopLink map contains the information about how classes map to database tables. Use the TopLink editor to edit each component of the mappings, including:

Database information, such as driver, URL, and login information.

Mapping defaults, such as identity map and cache options.

The TopLink editor in Oracle JDeveloper supports the following project types:

Relational project

XML project

EIS project

116.1.2 How to Create a Project Using TopLink Workbench

When you create a project using TopLink Workbench, all project information is stored in the project file ( .mwp file). This file references additional XML data files that contain the information about how the Java classes map to database tables or XML elements.

Using TopLink Workbench, you can export this information as a TopLink project XML file (that is, the deployment XML file) that is read in by the TopLink runtime. You can also export this information as a Java class. For more information, see Section 116.3, "Exporting Project Information".

TopLink Workbench displays projects and their contents in the Navigator window. When you select a project, its attributes are displayed in the Editor window. See Section 5.3.3, "How to Use the Navigator" for more information. TopLink Workbench supports the following project types:

/*** The class EmployeeProject is an example of an Oracle TopLink project defined in* Java code. The individual parts of the project - the Login and the descriptors,* are built inside of methods that are called by the constructor. Note that* EmployeeProject extends the class oracle.toplink.sessions.Project*/
public class EmployeeProject extends oracle.toplink.sessions.Project {
/*** Supply a zero-argument constructor that initializes all aspects of the project.* Make sure that the login and all the descriptors are initialized and added to* the project. Project-level properties, such as the name of the project, should* be specified here*/
public EmployeeProject() {
setName("EmployeeProject");
applyLogin();
addDescriptor(buildAddressDescriptor());
addDescriptor(buildEmployeeDescriptor());
addDescriptor(buildPhoneNumberDescriptor());
}
// Data source information
public void applyLogin() {
DatabaseLogin login = new DatabaseLogin();
// use platform appropriate for underlying database
login.usePlatform(
new oracle.toplink.platform.database.oracle.Oracle9Platform());
login.setDriverClassName("oracle.jdbc.OracleDriver");
login.setConnectionString("jdbc:oracle:thin:@HOST:PORT:SID");
login.setUserName("USER NAME");
login.setEncryptedPassword("PASSWORD, ENCRYPTED");
// Configuration Properties
setDatasourceLogin(login);
}
/*** Descriptors are built by defining table info, setting properties* (caching, etc.) and by adding mappings to the descriptor*/// SECTION: DESCRIPTOR
public ClassDescriptor buildAddressDescriptor() {
RelationalDescriptor descriptor = new RelationalDescriptor();
// specify the class to be made persistent
descriptor.setJavaClass(examples.servletjsp.model.Address.class);
// specify the tables to be used and primary key
descriptor.addTableName("ADDRESS");
descriptor.addPrimaryKeyFieldName("ADDRESS.ADDRESS_ID");
// Descriptor Properties
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100)
descriptor.useRemoteSoftCacheWeakIdentityMap()
descriptor.setRemoteIdentityMapSize(100)
descriptor.setSequenceNumberFieldName("ADDRESS.ADDRESS_ID")
descriptor.setSequenceNumberName("ADD_SEQ");
descriptor.setAlias("Address");
// Mappings
DirectToFieldMapping cityMapping = new DirectToFieldMapping();
cityMapping.setAttributeName("city");
cityMapping.setFieldName("ADDRESS.CITY");
descriptor.addMapping(cityMapping);
// Additional mappings are added to the descriptor using the addMapping method
return descriptor;}

116.2.1 How to Open Existing Projects

Use this procedure to open an existing project:

Caution:

For most prior release projects, simply opening the project in TopLink Workbench will upgrade your project. However, to upgrade release 9.0.3 (and earlier) projects, you must follow specific upgrade procedures and use the Package Rename tool.

Refer to Oracle TopLink Release Notes for more information.

Click Open Project on the toolbar. The Choose a File dialog box appears. You can also open a project by choosing File > Open from the menu.

Do not rename the .mwp file outside of TopLink Workbench. To rename a project, use the Save As option.

116.2.3 How to Generate the Project Status Report

Use the project status report to display a list of all warnings and errors in the TopLink Workbench project. This report is similar to the Problems window (see Section 5.3, "Using TopLink Workbench"), but lets you easily copy and paste the errors into documents or messages. To generate the project status report, use this procedure: