Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Creating a Project (ELUG)

This section describes how to create EclipseLink projects. For information on the various types of projects available, see EclipseLink Project Types.

You can create a project using the Workbench or Java code. We recommend using the Workbench to create projects and generate deployment XML or Java source versions of the project for use at run time.

Alternatively, you can create projects in Java code. For an EIS project that uses a record type other than XML, you must use Java code.

How to Create a Project Using the Workbench

When you create a project using the 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 the Workbench, you can export this information as an EclipseLink project XML file (that is, the deployment XML file) that is read in by the EclipseLink runtime. You can also export this information as a Java class.

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

  • Relational Database project icon Relational project
  • XML Project icon XML project
  • EIS project icon EIS project

Creating New Workbench Projects

This section includes information on creating a new Workbench project. To create a new project from an existing persistence application, see Integrating EclipseLink with an Application Server. To create a new project from JAXB, see EclipseLink Support for Java Architecture for XML Binding (JAXB).

To create a new Workbench project, use this procedure:

  1. Click New New Project icon on the toolbar and select Project. The Create New Workbench Project dialog box appears.
    You can also create a new project by choosing File > New > Project from the menu.
    Create New Workbench Project Dialog Box

    Create New Workbench Project Dialog Box

  2. Enter data in each field on the Create New Workbench Project dialog box, and then click OK.

Use the following information to enter data in each field of this dialog box:

Field Description
Name Enter the name of the Workbench project. This project name will also become the name of the .mwp file.
Data Source Use these options to specify the type of project to create, and its data source.

Select Database to create a relational project to a relational database. Use the Platform list to select the specific database platform.


Select EIS to create an EIS project to a nonrelational data source using XML records. Use the Platform list to specify the JCA adapter to use.


Select XML to create a nontransactional, nonpersistent XML project to an XML schema. Alternatively, you can generate both an XML project and object model classes (see Creating an XML Project from an XML Schema).

For more project information, continue with the following:

How to Create a Project Using Java

To create a project using Java code, use this procedure:

  1. Implement a project class that extends the org.eclipse.persistence.sessions.Project class (see the Specifying an EclipseLink Project in Code example).
  2. Compile the project class.

Specifying an EclipseLink Project in Code

* The class EmployeeProject is an example of an EclipseLink 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 org.eclipse.persistence.sessions.Project
public class EmployeeProject extends org.eclipse.persistence.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() {

// Data source information
public void applyLogin() {
  DatabaseLogin login = new DatabaseLogin();

  // use platform appropriate for underlying database
  login.setUserName("USER NAME");
  login.setEncryptedPassword("PASSWORD, ENCRYPTED");

  // Configuration Properties


* Descriptors are built by defining table info, setting properties
* (caching, etc.) and by adding mappings to the descriptor

public ClassDescriptor buildAddressDescriptor() {

  RelationalDescriptor descriptor = new RelationalDescriptor();

  // specify the class to be made persistent

  // specify the tables to be used and primary key


  // Descriptor Properties

  // Mappings
  DirectToFieldMapping cityMapping = new DirectToFieldMapping();

  // Additional mappings are added to the descriptor using the addMapping method

  return descriptor;}

Note: Using Workbench provides a starting point for a custom project class. For more information, see How to Export Project Java Source Using Workbench.

Working with Projects

Using Workbench, you can perform the following project functions:

See Configuring a Project for additional information on working with Workbench projects.

How to Open Existing Projects

Use this procedure to open an existing project:

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

Note:The File menu option contains a list of recently opened projects. You can select one of these projects to open. See How to Use General Preferences for information on customizing this list.

See Also

Working with Projects
Introduction to Projects

How to Save Projects

Workbench does not automatically save your project. Be sure to save your project often to avoid losing data.

To save your project(s), use this procedure:

  1. Click Save Save Selected Project button. or Save All Save All Projects button. to save your project(s).
    You can also save a project by choosing File > Save or File > Save All from the menu.
  2. If you close Workbench while there are currently unsaved changes, the Save Project dialog box appears.
    Save Projects Dialog Box
    Save Projects Dialog Box

  3. Select the project(s) to save and click OK.Click Select All to select all the available projects.

To save your project with a new name or location, see Saving Projects with a New Name or Location.

Saving Projects with a New Name or Location

To save your project with a different name or location, use this procedure:

  1. Choose File > Save As Save As button. The Save As dialog box appears.
    Save As Dialog Box
    Save As Dialog Box

  2. Select a name and location, then click Save.

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

How to Generate the Project Status Report

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

  1. Project Status Report button Right-click the Problems label above the Problems window and select Problem Report. The Project Status Report dialog box appears, displaying the status of each Workbench project.
    You can also generate the project status report by selecting Tools > Problem Report from the menu.
    Problem Report Dialog Box
    Problem Report Dialog Box

  2. See EclipseLink Workbench Error Reference (ELUG) for information on each reported error.
  3. To copy the report to another application, click Copy.

Exporting Project Information

To use your project with the EclipseLink Foundation Library at run time, you must either generate deployment XML or export the project to Java source code.

For all project types, Workbench can generate and export the following project information:

Note:When exporting Java source and deployment XML, Workbench writes the database password (if applicable) using Java Cryptography Extension (JCE) encryption. For information on how to specify password encryption options, see Configuring Password Encryption.

How to Export Deployment XML Information Using Workbench

To export your deployment XML file (project.xml), use this procedure (see Creating EclipseLink Files for Deployment for detailed information):

  1. Select the project and click Export Deployment XML expxml.gif.
    You can also right-click the project in the Navigator and choose Export > Project Deployment XML from the context menu or choose Selected > Export > Project Deployment XML from the menu.
  2. If you have not defined deployment and source code generation defaults (see Configuring a Project) Workbench prompts for a file name and directory.

Note: If your project contains errors, the project.xml may not be valid. See for information on each reported error.

How to Export Model Java Source Using Workbench

To generate the project model's Java source code, use this procedure:

  1. Right-click the project, package, or specific descriptor in the Navigator and choose Export > Export Model Java Source from the context menu. Workbench creates a .java file for each selected descriptor.
    You can also choose Workbench > Export > Export Model Java Source or Selected > Export > Model Java Source from the menu or click Generate Source Code on the Class tab. See Configuring Class Information for more information.
  2. Click Generate Source Code to generate the project's model Java source.

If you have not defined deployment and source code generation defaults (see Configuring a Project) Workbench prompts for a root directory.

Note: If your Workbench project uses UTF-8 character set, you must use a compatible JDK when compiling the exported Java source.

Copyright Statement

Copyright © Eclipse Foundation, Inc. All Rights Reserved.