Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Creating a Project (ELUG)"

m
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
[[Special:Whatlinkshere/Creating a Project (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Creating a Project (ELUG)|Related Topics]]</div>
This section describes how to create EclipseLink projects.
+
This section describes how to create EclipseLink projects. For information on the various types of projects available, see [[Introduction%20to%20Projects (ELUG)#EclipseLink Project Types|EclipseLink Project Types]].
  
For information on the various types of projects available, see [[Introduction%20to%20Projects (ELUG)|EclipseLink Project Types]].
+
You can create a project using the Workbench or Java code. We recommend [[#How to Create a Project Using the Workbench|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 [[#How to Create a Project Using Java|in Java code]]. For an EIS project that uses a record type other than XML, you must use Java code.  
 
+
==Introduction to the Project Creation==
+
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. For more information, see [[#How to Create a Project Using the Workbench|How to Create a Project Using the Workbench]].
+
 
+
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. For more information, see [[#How to Create a Project Using Java|How to Create a Project Using Java]] and EclipseLink API Reference.
+
 
+
For information on how to create a project using Java, see [[#How to Create a Project Using Java|How to Create a Project Using Java]].
+
  
  
  
 
===How to Create a Project Using the Workbench===
 
===How to Create a Project Using the Workbench===
When you create a project using Workbench, all project information is stored in the project file ( .<tt>mwp</tt> file). This file references additional XML data files that contain the information about how the Java classes map to database tables or XML elements.
+
When you create a project using the Workbench, all project information is stored in the project file ( .<tt>mwp</tt> 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 Workbench, you can export this information as a 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. For more information, see [[#Exporting Project Information|Exporting Project Information]].
+
Using the Workbench, you can [[#Exporting Project Information|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.  
  
Workbench displays projects and their contents in the Navigator window. When you select a project, its attributes are displayed in the Editor window. See [[Using%20Workbench%20(ELUG)|How to Use the Navigator]] for more information. Workbench supports the following project types:
+
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 [[Using%20Workbench%20(ELUG)#How to Use the Navigator|How to Use the Navigator]] for more information. The Workbench supports the following project types:
* [[Image:projdb.gif|Relational Database project icon]]<br> Relational project
+
* [[Image:projdb.gif|Relational Database project icon]] Relational project
* [[Image:projxml.gif|XML Project icon]]<br> XML project
+
* [[Image:projxml.gif|XML Project icon]] XML project
* [[Image:projeis.gif|EIS project icon]]<br> EIS project
+
* [[Image:projeis.gif|EIS project icon]] EIS project
  
  
  
 
====Creating New Workbench Projects====
 
====Creating New Workbench Projects====
This section includes information on creating a new Workbench project. To create a new project from an existing persistence application (such as OC4J), see [[Integrating%20EclipseLink%20with%20an%20Application%20Server%20(ELUG)|Integrating EclipseLink with an Application Server]]. To create a new project from JAXB, see [[Introduction%20to%20XML%20Projects%20(ELUG)|EclipseLink Support for Java Architecture for XML Binding (JAXB)]].
+
This section includes information on creating a new Workbench project. To create a new project from an existing persistence application, see [[Integrating%20EclipseLink%20with%20an%20Application%20Server%20(ELUG)|Integrating EclipseLink with an Application Server]]. To create a new project from JAXB, see [[Introduction%20to%20XML%20Projects%20(ELUG)#EclipseLink Support for Java Architecture for XML Binding (JAXB)|EclipseLink Support for Java Architecture for XML Binding (JAXB)]].
  
 
To create a new Workbench project, use this procedure:
 
To create a new Workbench project, use this procedure:
# [[Image:creatbtn.gif|New Project icon]]<br> Click '''New''' 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.'''''<br><span id="Figure 112-1"></span> Create New Workbench Project Dialog Box '''''<br>[[Image:create.gif|Create New Workbench Project Dialog Box]]<br><br>
+
# Click '''New''' [[Image:creatbtn.gif|New Project icon]] on the toolbar and select '''Project'''. The Create New Workbench Project dialog box appears.<br>You can also create a new project by choosing '''File''' > '''New > Project''' from the menu.'''''<br><span id="Figure 112-1"></span> Create New Workbench Project Dialog Box '''''<br>[[Image:create.gif|Create New Workbench Project Dialog Box]]<br><br>
 
# Enter data in each field on the Create New Workbench Project dialog box, and then click '''OK'''.
 
# Enter data in each field on the Create New Workbench Project dialog box, and then click '''OK'''.
  
Line 50: Line 41:
 
| headers="r3c1-t2 r1c2-t2" align="left" | Use these options to specify the type of project to create, and its data source.
 
| headers="r3c1-t2 r1c2-t2" align="left" | Use these options to specify the type of project to create, and its data source.
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r4c1-t2" headers="r1c1-t2" align="left" | ''' Database'''
+
| id="r4c1-t2" headers="r1c1-t2" align="left" |  
 +
:''' Database'''
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
| headers="r4c1-t2 r1c2-t2" align="left" |
Select '''Database''' to create an relational project to a relational database. Use the '''Platform''' list to select the specific database platform. See [[Introduction%20to%20Relational%20Projects%20(ELUG)|Introduction to Relational Projects]] for more information.
+
Select '''Database''' to create a [[Introduction%20to%20Relational%20Projects%20(ELUG)|relational project]] to a relational database. Use the '''Platform''' list to select the specific database platform.  
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r5c1-t2" headers="r1c1-t2" align="left" | ''' EIS'''
+
| id="r5c1-t2" headers="r1c1-t2" align="left" |  
 +
:''' EIS'''
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
| headers="r5c1-t2 r1c2-t2" align="left" |
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.See [[Introduction%20to%20EIS%20Projects%20(ELUG)|Introduction to EIS Projects]] for more information.
+
Select '''EIS''' to create an [[Introduction%20to%20EIS%20Projects%20(ELUG)|EIS project]] to a nonrelational data source using XML records. Use the '''Platform''' list to specify the JCA adapter to use.
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r6c1-t2" headers="r1c1-t2" align="left" | ''' XML'''
 
| id="r6c1-t2" headers="r1c1-t2" align="left" | ''' XML'''
 
| headers="r6c1-t2 r1c2-t2" align="left" |
 
| headers="r6c1-t2 r1c2-t2" align="left" |
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%20an%20XML%20Project%20(ELUG)|Creating an XML Project from an XML Schema]]).See [[Introduction%20to%20XML%20Projects%20(ELUG)|Introduction to XML Projects]] for more information.
+
Select '''XML''' to create a nontransactional, nonpersistent [[Introduction%20to%20XML%20Projects%20(ELUG)|XML project]] to an XML schema. Alternatively, you can generate both an XML project and object model classes (see [[Creating%20an%20XML%20Project%20(ELUG)#Creating an XML Project from an XML Schema|Creating an XML Project from an XML Schema]]).
 
|}
 
|}
  
Line 66: Line 59:
  
 
For more project information, continue with the following:
 
For more project information, continue with the following:
* Configure the project (see [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]]).
+
* [[Configuring%20a%20Project%20(ELUG)|Configuring the project]].
 
* Add mappings and descriptors (see [[Introduction%20to%20Descriptors%20(ELUG)|Introduction to Descriptors]] and [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]]).
 
* Add mappings and descriptors (see [[Introduction%20to%20Descriptors%20(ELUG)|Introduction to Descriptors]] and [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]]).
* Export the project for use with the EclipseLink runtime (see [[#Exporting Project Information|Exporting Project Information]]).
+
* [[#Exporting Project Information|Export the project for use with the EclipseLink runtime]].
 
+
 
+
  
 
===How to Create a Project Using Java===
 
===How to Create a Project Using Java===
 
To create a project using Java code, use this procedure:
 
To create a project using Java code, use this procedure:
# Implement a project class that extends the <tt>org.eclipse.persistence.sessions.Project</tt> class (see [[#Example 112-1|Specifying a EclipseLink Project in Code]]).
+
# Implement a project class that extends the <tt>org.eclipse.persistence.sessions.Project</tt> class (see the [[#Example 112-1|Specifying an EclipseLink Project in Code]] example).
 
# Compile the project class.
 
# Compile the project class.
  
  
 
<span id="Example 112-1"></span>
 
<span id="Example 112-1"></span>
''''' Specifying a EclipseLink Project in Code'''''
+
''''' Specifying an EclipseLink Project in Code'''''
 
  '''/**'''
 
  '''/**'''
 
  '''<nowiki>* The class EmployeeProject is an example of an EclipseLink project defined in</nowiki>
 
  '''<nowiki>* The class EmployeeProject is an example of an EclipseLink project defined in</nowiki>
Line 162: Line 153:
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
| align="left" |
 
| align="left" |
'''Note'''<nowiki>:</nowiki> Using Workbench provides a starting point for a custom project class. For more information, see [[Creating%20a%20Relational%20Project%20(ELUG)|How to Export Project Java Source Using Workbench]].
+
'''Note'''<nowiki>:</nowiki> Using Workbench provides a starting point for a custom project class. For more information, see [[Creating%20a%20Relational%20Project%20(ELUG)#How to Export Project Java Source Using Workbench|How to Export Project Java Source Using Workbench]].
 
|}
 
|}
  
Line 182: Line 173:
 
Use this procedure to open an existing project:
 
Use this procedure to open an existing project:
  
# [[Image:openbtn.gif|Open Project button]]<br> 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.<br>
+
#Click '''Open Project'''  [[Image:openbtn.gif|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.<br>
  
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
| align="left" |
 
| align="left" |
'''Note'''<nowiki>:</nowiki>The '''File''' menu option contains a list of recently opened projects. You can select one of these projects to open. See [[Using%20Workbench%20(ELUG)|How to Use General Preferences]] for information on customizing this list.
+
'''Note'''<nowiki>:</nowiki>The '''File''' menu option contains a list of recently opened projects. You can select one of these projects to open. See [[Using%20Workbench%20(ELUG)#How to Use General Preferences|How to Use General Preferences]] for information on customizing this list.
 
|}<br>
 
|}<br>
  
Line 192: Line 183:
  
 
'''See Also'''
 
'''See Also'''
: [[#Working with Projects]]
+
: [[#Working with Projects|Working with Projects]]
: [[Introduction%20to%20Projects|Introduction to Projects]]
+
: [[Introduction%20to%20Projects (ELUG)|Introduction to Projects]]
  
  
Line 201: Line 192:
  
 
To save your project(s), use this procedure:
 
To save your project(s), use this procedure:
# [[Image:savebtn.gif|Save Selected Project button.]]<br>[[Image:saveall.gif|Save All Projects button.]]<br> Click '''Save''' or '''Save All''' to save your project(s).You can also save a project by choosing '''File''' > '''Save''' or '''File''' > '''Save All''' from the menu.
+
# Click '''Save''' [[Image:savebtn.gif|Save Selected Project button.]] or '''Save All''' [[Image:saveall.gif|Save All Projects button.]] to save your project(s).<br>You can also save a project by choosing '''File''' > '''Save''' or '''File''' > '''Save All''' from the menu.
 
# If you close Workbench while there are currently unsaved changes, the Save Project dialog box appears.<br><span id="Figure 112-3"></span>''''' Save Projects Dialog Box'''''<br>[[Image:save.gif|Save Projects Dialog Box]]<br><br>
 
# If you close Workbench while there are currently unsaved changes, the Save Project dialog box appears.<br><span id="Figure 112-3"></span>''''' Save Projects Dialog Box'''''<br>[[Image:save.gif|Save Projects Dialog Box]]<br><br>
 
# Select the project(s) to save and click '''OK'''.Click '''Select All''' to select all the available projects.
 
# Select the project(s) to save and click '''OK'''.Click '''Select All''' to select all the available projects.
Line 211: Line 202:
 
====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:
 
To save your project with a different name or location, use this procedure:
# [[Image:saveasbt.gif|Save As button]]<br> Choose '''File''' > '''Save As'''. The Save As dialog box appears.<br><span id="Figure 112-4"></span>''''' Save As Dialog Box'''''<br>[[Image:saveas.gif|Save As Dialog Box]]<br><br>
+
# Choose '''File''' > '''Save As''' [[Image:saveasbt.gif|Save As button]]. The Save As dialog box appears.<br><span id="Figure 112-4"></span>''''' Save As Dialog Box'''''<br>[[Image:saveas.gif|Save As Dialog Box]]<br><br>
 
# Select a name and location, then click '''Save'''.
 
# Select a name and location, then click '''Save'''.
  
Line 228: Line 219:
 
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%20Workbench%20(ELUG)|Using Workbench]]), but lets you easily copy and paste the errors into documents or messages. To generate the project status report, use this procedure:
 
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%20Workbench%20(ELUG)|Using Workbench]]), but lets you easily copy and paste the errors into documents or messages. To generate the project status report, use this procedure:
  
# [[Image:strptbtn.gif|Project Status Report button]]<br> 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.<br><span id="Figure 112-5"></span>''''' Problem Report Dialog Box'''''<br>[[Image:statrpt.gif|Problem Report Dialog Box]]<br><br>
+
# [[Image:strptbtn.gif|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.<br>You can also generate the project status report by selecting '''Tools''' > '''Problem Report''' from the menu.<br><span id="Figure 112-5"></span>''''' Problem Report Dialog Box'''''<br>[[Image:statrpt.gif|Problem Report Dialog Box]]<br><br>
 +
#See [[EclipseLink Workbench Error Reference (ELUG)]] for information on each reported error.
 +
#To copy the report to another application, click '''Copy'''.
  
See for information on each reported error.
 
 
To copy the report to another application, click '''Copy'''.
 
 
'''See Also'''
 
: [[#How to Generate the Project Status Report|How to Generate the Project Status Report]]
 
  
  
  
 
==Exporting Project Information==
 
==Exporting Project Information==
To use your project with the EclispeLink Foundation Library at run time, you must either generate deployment XML or export the project to Java source code.
+
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:
 
For all project types, Workbench can generate and export the following project information:
Line 259: Line 246:
 
===How to Export Deployment XML Information Using Workbench===
 
===How to Export Deployment XML Information Using Workbench===
 
To export your deployment XML file (<tt>project.xml</tt>), use this procedure (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|Creating EclipseLink Files for Deployment]] for detailed information):
 
To export your deployment XML file (<tt>project.xml</tt>), use this procedure (see [[Creating%20EclipseLink%20Files%20for%20Deployment%20(ELUG)|Creating EclipseLink Files for Deployment]] for detailed information):
# [[Image:expxml.gif|Export Deployment XML button]]<br> Select the project and click '''Export Deployment XML'''.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.If you have not defined deployment and source code generation defaults (see [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]]) Workbench prompts for a file name and directory.
+
# Select the project and click '''Export Deployment XML''' [[Image:expxml.gif|expxml.gif]].<br>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.
 +
#If you have not defined deployment and source code generation defaults (see [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]]) Workbench prompts for a file name and directory.
  
 
<br>
 
<br>
Line 274: Line 262:
 
===How to Export Model Java Source Using Workbench===
 
===How to Export Model Java Source Using Workbench===
 
To generate the project model's Java source code, use this procedure:
 
To generate the project model's Java source code, use this procedure:
# 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 <tt>.java</tt> 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 [[Using%20Workbench%20(ELUG)|Configuring Class Information]] for more information.
+
# 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 <tt>.java</tt> file for each selected descriptor.<br>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 [[Using%20Workbench%20(ELUG)|Configuring Class Information]] for more information.
 
# Click '''Generate Source Code''' to generate the project's model Java source.
 
# Click '''Generate Source Code''' to generate the project's model Java source.
  
Line 295: Line 283:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1]]
 
[[Category: Task]]
 
[[Category: Task]]

Latest revision as of 14:56, 18 September 2008

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.
Database

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

EIS

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.

XML

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() {
  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 org.eclipse.persistence.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;}


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

Back to the top