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 "Configuring a Relational Project (ELUG)"

m (How to Configure Development and Deployment Logins Using Workbench)
m
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Image:Elug draft icon.png]] '''For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/ '''
 +
 +
----
 +
 
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="margin:5px;float:right;border:1px solid #000000;padding:5px">__TOC__
 
[[Special:Whatlinkshere/Configuring a Relational Project (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Configuring a Relational Project (ELUG)|Related Topics]]</div>
Line 4: Line 8:
  
 
This section also describes logging into a database during development when using Workbench. For more information, see [[#Logging In to the Database|Logging In to the Database]].
 
This section also describes logging into a database during development when using Workbench. For more information, see [[#Logging In to the Database|Logging In to the Database]].
 +
 +
For information on how to create relational projects, see [[Creating%20a%20Relational%20Project%20(ELUG)|Creating a Relational Project]].
  
 
This table lists the configurable options for relational projects. In addition to the configurable options described here, you must also configure the base class options described in [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]].
 
This table lists the configurable options for relational projects. In addition to the configurable options described here, you must also configure the base class options described in [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]].
Line 187: Line 193:
  
 
[[#How to Configure Sequencing at the Project Level Using Java|Using Java]], you can configure any sequence type that EclipseLink supports (see [[Introduction%20to%20Relational%20Projects%20(ELUG)#Sequencing Types|Sequencing Types]]). You can create any number and combination of sequences. You can create a sequence object explicitly or use the default sequence that the platform creates. You can associate the same sequence with more than one descriptor and you can configure a separate preallocation size for each descriptor's sequence.
 
[[#How to Configure Sequencing at the Project Level Using Java|Using Java]], you can configure any sequence type that EclipseLink supports (see [[Introduction%20to%20Relational%20Projects%20(ELUG)#Sequencing Types|Sequencing Types]]). You can create any number and combination of sequences. You can create a sequence object explicitly or use the default sequence that the platform creates. You can associate the same sequence with more than one descriptor and you can configure a separate preallocation size for each descriptor's sequence.
 
If you are migrating a BEA WebLogic CMP application to OC4J and EclipseLink persistence, you must manually configure your project to use EclipseLink unary sequence tables if your application originally used single column sequence tables in BEA WebLogic.
 
  
 
After configuring the sequence type at the project (or session) level, to enable sequencing, you must [[Configuring%20a%20Relational%20Descriptor%20(ELUG)#Configuring Sequencing at the Descriptor Level|configure a descriptor with a sequence field and a sequence name]].
 
After configuring the sequence type at the project (or session) level, to enable sequencing, you must [[Configuring%20a%20Relational%20Descriptor%20(ELUG)#Configuring Sequencing at the Descriptor Level|configure a descriptor with a sequence field and a sequence name]].
Line 239: Line 243:
  
 
Using Java, you can configure a project to use multiple, different sequences, as this exmaple shows.
 
Using Java, you can configure a project to use multiple, different sequences, as this exmaple shows.
 
  
 
<span id="Example 25-1"></span>
 
<span id="Example 25-1"></span>
 
''''' Configuring Sequencing at the Project Level in Java'''''
 
''''' Configuring Sequencing at the Project Level in Java'''''
  '''// Enable native sequencing for the project as the default. Configured the default'''   
+
<source lang="java">
  '''// preallocation size'''
+
  // Enable native sequencing for the project as the default. Configured the default
 +
  // preallocation size'''
 
  project.getLogin().useNativeSequencing();
 
  project.getLogin().useNativeSequencing();
 
  project.getLogin().setSequencePreallocationSize(50);
 
  project.getLogin().setSequencePreallocationSize(50);
 
   
 
   
  '''// Configure the EMP_SEQ to not use preallocation'''
+
  // Configure the EMP_SEQ to not use preallocation
 
  DefaultSequence empSequence = new DefaultSequence("EMP_SEQ", 1);
 
  DefaultSequence empSequence = new DefaultSequence("EMP_SEQ", 1);
 
  project.getLogin().addSequence(empSequence);
 
  project.getLogin().addSequence(empSequence);
 
   
 
   
  '''// Configure the PROJ_SEQ to use a seperate sequence table'''
+
  // Configure the PROJ_SEQ to use a seperate sequence table
 
  UnarySequence projSequence = new UnarySequence("PROJ_SEQ_TAB", "COUNTER");
 
  UnarySequence projSequence = new UnarySequence("PROJ_SEQ_TAB", "COUNTER");
 
  project.getLogin().addSequence(projSequence);
 
  project.getLogin().addSequence(projSequence);
 +
</source>
  
 
==Configuring Login Information at the Project Level==
 
==Configuring Login Information at the Project Level==
Line 305: Line 310:
  
  
'''See Also'''
+
See Also:
 
: [[#Configuring Login Information at the Project Level|Configuring Login Information at the Project Level]]
 
: [[#Configuring Login Information at the Project Level|Configuring Login Information at the Project Level]]
 
: [[#Configuring Relational Database Platform at the Project Level|Configuring Relational Database Platform at the Project Level]]
 
: [[#Configuring Relational Database Platform at the Project Level|Configuring Relational Database Platform at the Project Level]]
 
: [[#Configuring Development and Deployment Logins|Configuring Development and Deployment Logins]]
 
: [[#Configuring Development and Deployment Logins|Configuring Development and Deployment Logins]]
 +
 +
  
 
==Configuring Development and Deployment Logins==
 
==Configuring Development and Deployment Logins==
Line 357: Line 364:
 
: [[#Configuring Development and Deployment Logins|Configuring Development and Deployment Logins]]
 
: [[#Configuring Development and Deployment Logins|Configuring Development and Deployment Logins]]
 
: [[Introduction%20to%20Projects (ELUG)#Development Role|Development Role]]
 
: [[Introduction%20to%20Projects (ELUG)#Development Role|Development Role]]
 +
 +
  
 
==Logging In to the Database==
 
==Logging In to the Database==
Line 448: Line 457:
 
|}
 
|}
  
'''See Also'''
+
See Also:
 
: [[#Configuring Named Query Parameterized SQL and Statement Caching at the Project Level|Configuring Named Query Parameterized SQL and Statement Caching at the Project Level]]
 
: [[#Configuring Named Query Parameterized SQL and Statement Caching at the Project Level|Configuring Named Query Parameterized SQL and Statement Caching at the Project Level]]
 
: [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]]
 
: [[Configuring%20a%20Project%20(ELUG)|Configuring a Project]]
Line 546: Line 555:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1]]
 
[[Category: Task]]
 
[[Category: Task]]
 
[[Category: ORM]]
 
[[Category: ORM]]

Latest revision as of 11:25, 18 July 2012

Elug draft icon.png For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/


Related Topics

This section describes the various components that you must configure in order to use a relational project.

This section also describes logging into a database during development when using Workbench. For more information, see Logging In to the Database.

For information on how to create relational projects, see Creating a Relational Project.

This table lists the configurable options for relational projects. In addition to the configurable options described here, you must also configure the base class options described in Configuring a Project.


Option to Configure EclipseLink Workbench Java

Project save location

Supported

Unsupported

Project classpath

Supported

Unsupported

Project comments

Supported

Unsupported

Method or direct field access)

Supported

Supported

Default descriptor advanced properties

Supported

Supported

Existence checking

Supported

Supported

Project deployment XML options

Supported

Supported

Model Java source code options

Supported

Supported

Relational database

Supported

Supported

Sequencing

Supported

Supported

Login information

Supported

Supported

Development and deployment logins

Supported

Unsupported

Cache type and size

Supported

Supported

Cache isolation

Supported

Supported

Cache coordination change propagation

Supported

Supported

Cache expiration

Supported

Unsupported

Named query parameterized SQL and statement caching

Supported

Unsupported

Table generation options

Supported

Unsupported

Table creator Java source options

Supported

Unsupported

Project Java source code options

Supported

Unsupported

For more information, see Introduction to Relational Projects.


Configuring Relational Database Platform at the Project Level

For each relational project, you must specify the database platform (such as Oracle Database 10g). This platform configuration is overridden by the session login, if configured.

For more information, see the following:


How to Configure Relational Database Platform at the Project Level Using Workbench

To specify the database platform of a relational project, use this procedure:

  1. Select the database object in the Navigator. The Database property sheet appears.
    Database Property Sheet, Database Platform Options
    Database Property Sheet, Database Platform Options
  2. Complete the Database Platform option on the property sheet.
  3. Click Change to select a new database platform for the project. For more information, see Data Source Platform Types.


Configuring Sequencing at the Project Level

Sequencing allows EclipseLink to automatically assign the primary key or ID of an object when the object is inserted.

You configure EclipseLink sequencing at the project or session level to tell EclipseLink how to obtain sequence values: that is, what type of sequences to use.

In a POJO project, you can configure a session directly: in this case, you can use a session-level sequence configuration to override project-level sequence configuration, on a session-by-session basis), if required (see .

Using the Workbench, you can configure Table Sequencing and native sequencing (see Native Sequencing with an Oracle Database Platform and Native Sequencing with a Non-Oracle Database Platform), and you can configure a preallocation size that applies to all sequences (see Sequencing and Preallocation Size).

Using Java, you can configure any sequence type that EclipseLink supports (see Sequencing Types). You can create any number and combination of sequences. You can create a sequence object explicitly or use the default sequence that the platform creates. You can associate the same sequence with more than one descriptor and you can configure a separate preallocation size for each descriptor's sequence.

After configuring the sequence type at the project (or session) level, to enable sequencing, you must configure a descriptor with a sequence field and a sequence name.

For more information about sequencing, see Sequencing in Relational Projects.


How to Configure Sequencing at the Project Level Using Workbench

To specify the sequencing information for the project, use this procedure:

  1. Select the project object in the Navigator.
  2. Select the Sequencing tab in the Editor. The Sequencing tab appears.
    Sequencing Tab
    Sequencing Tab
  3. Complete each field on Sequencing tab.

Use this table to enter data in the following fields to configure the sequencing information:

Field Description
Preallocation Size

Specify the default preallocation size (see Sequencing and Preallocation Size). Default is 50. The preallocation size you configure applies to all sequences.

Default Sequence Table

Select this option to use table sequencing (see Table Sequencing) with default sequence table name SEQUENCE, default sequence name field SEQ_NAME, and default sequence counter field SEQ_COUNT.

Native Sequencing

Select this option to use a sequencing object (see Native Sequencing with an Oracle Database Platform or Native Sequencing with a Non-Oracle Database Platform) created by the database platform. This option applies only to Oracle, Sybase, Microsoft SQL, and IBM Informix database platforms.

Custom Sequence Table

Select this option to use table sequencing (see Table Sequencing) with a sequence table name, sequence name field, and sequence counter field name that you specify.

Name Specify the name of the sequence table.
Name Field Specify the name of the column used to store the sequence name.
Counter Field Specify the name of the column used to store the sequence count.


How to Configure Sequencing at the Project Level Using Java

Using Java, you can configure a project to use multiple, different sequences, as this exmaple shows.

Configuring Sequencing at the Project Level in Java

 // Enable native sequencing for the project as the default. Configured the default
 // preallocation size'''
 project.getLogin().useNativeSequencing();
 project.getLogin().setSequencePreallocationSize(50);
 
 // Configure the EMP_SEQ to not use preallocation
 DefaultSequence empSequence = new DefaultSequence("EMP_SEQ", 1);
 project.getLogin().addSequence(empSequence);
 
 // Configure the PROJ_SEQ to use a seperate sequence table
 UnarySequence projSequence = new UnarySequence("PROJ_SEQ_TAB", "COUNTER");
 project.getLogin().addSequence(projSequence);

Configuring Login Information at the Project Level

This section describes how to define a login to a relational database. After you define a login, you must designate its role.

After you create a login and specify it as a development login, you can log in to a database instance.


How to Configure Login Information at the Project Level UsingWorkbench

To create or edit a database login, use this procedure:

  1. Select the database object in the Navigator. The Database property sheet appears.
    Database Property Sheet, Database Login Fields
    Database Property Sheet, Database Login Fields
  2. Click Add to create a new Defined Login.
  3. Complete the Database Login fields on the property sheet.

Use this table to enter data in the following fields on the Database property sheet to configure the database login:

Field Description
Defined Logins Login used to access the database. Click Add to add a new login, or Remove to delete an existing login.
Driver Class The JDBC driver to use to connect to the database.
URL The URL used to connect to the appropriate database.
User Name The name required to log in to the database.
Password The password required to log in to the database.
Save Password

Whether or not to save the Password for this Defined Login.

We recommend that you do not save the password with a deployment login.

Note: If you select Save Password, then when you export Java source and deployment XML, Workbench writes the database password using JCE encryption (when using JDK 1.4 or later). For information on how to specify password encryption options, see Configuring Password Encryption.

Default: unselected.


See Also:

Configuring Login Information at the Project Level
Configuring Relational Database Platform at the Project Level
Configuring Development and Deployment Logins


Configuring Development and Deployment Logins

This section describes how to designate a defined login's role. For information on how to define a login, see Configuring Login Information at the Project Level. EclipseLink recognizes the following login roles:


Development Role

While using Workbench to develop a project (see Development Role), you must define a login (see Configuring Login Information at the Project Level) and designate it as the development login. The development login is stored in the EclipseLink project file. Workbench use the information in the development login whenever you perform a data source operation from within Workbench. For example, when you read or write schema information from or to a data source during application development, the development login information is never written to a sessions.xml or project.xml file and is overridden by the deployment login (or the session login) at run time.

For more information on how to use a development login to connect to a database, see Logging In to the Database.


POJO Session Role

If you are creating a POJO project, we recommend that you use the sessions.xml file to store the sessions your project uses at run time (see Data Source Login Types).


How to Configure Development and Deployment Logins Using Workbench

To specify different development and deployment database logins, use this procedure:

  1. Select the database object in the Navigator. The Database property sheet appears.
    Database Property Sheet, Development and Deployment Login Options
    Database Property Sheet, Development and Deployment Login Options
  2. Complete the Development and Deployment Login options on the property sheet by selecting from the logins you configured previously.

Use this table to enter data in the following fields on the Database property sheet to configure the login:

Field Description
Development Login

The Defined Login to be used by Workbench during development to connect with the database, and to read or write table information.

For more information on how to use a development login to connect to a database, see Logging In to the Database.

Deployment Login The Defined Login to be used by your EclipseLink-enabled application during deployment.


See Also:

Configuring Development and Deployment Logins
Development Role


Logging In to the Database

Using Workbench, after you create a login and specify it as a development login, you can log in to a database instance.

You must log in to the database before importing or exporting table information.

To log in to the database using Workbench, use one of the following procedures:

  • Select the database object in the Navigator and click Login Database Login button. Workbench logs in to the database.
  • Right-click on the database object in the Navigator and choose Log In to Database from the context menu, or choose Selected > Log In to Database from the menu.

Database Logged In icon The database icon in the Navigator window changes to indicate you are now logged in to the database.


Configuring Named Query Parameterized SQL and Statement Caching at the Project Level

You can configure EclipseLink to use parameterized SQL (parameter binding) and prepared statement caching for all named queries and finders.

By default, EclipseLink uses parameterized SQL.

The use of parameterized SQL lets you create and store queries that are complete except for one or more bound parameters. The EclipseLink runtime binds the current parameter values when executing the query. This approach avoids the preparation of SQL execution and, thus, improves the performance of frequently executed SQL statements.

This section describes configuring parameterized SQL and statement caching options at the project level. This configuration applies to all named queries or finders (see Named Queries) you create on the descriptors in this project–not to all queries in general or write operations.

You can also configure parameterized SQL and statement caching options at the named query or finder-level to override this project-level configuration on a query-by-query basis (see Configuring Named Query Options) or at the session login-level (see Configuring JDBC Options).

For more information, see How to Use Parameterized SQL (Parameter Binding) and Prepared Statement Caching for Optimization.


Note: For applications using a Java EE data source or external connection pool, you must configure statement caching in the Java EE server's data source–not in EclipseLink.


This table summarizes which projects support parameterized SQL and statement caching configuration.

Project Support for Default Named Query Caching and Binding

Descriptor How to use the Workbench How to Use Java

Relational Projects

Supported.

Supported.

EIS Projects

Unsupported

Unsupported

XML Projects

Unsupported

Unsupported


How to Configure Named Query Parameterized SQL and Statement Caching at the Project Level Using Workbench

To specify the named query options, use this procedure:

  1. Select the project object in the Navigator.
  2. Select the Defaults tab in the Editor. The Defaults tab appears.
    Defaults Tab, Named Queries Options
    Defaults Tab, Named Queries Options
  3. Complete the Named Query options on the tab.

Use this table to enter data in following fields on the Defaults tab to specify the named query options for newly created descriptors.:

Field Description
Cache All Statements Caches the query's prepared statement in the EclipseLink statement cache.
Bind All Parameters

By default, EclipseLink binds all of the query's parameters. Deselect this option to disable binding.

See Also:

Configuring Named Query Parameterized SQL and Statement Caching at the Project Level
Configuring a Project


Configuring Table Generation Options

Using Workbench, you can configure options that apply when you generate database tables from the descriptors you define in your Workbench project. The resulting tables and columns will conform to the naming restrictions of the project's target database.


How to Configure Table Generation Options Using Workbench

To specify the default table generation options, use this procedure:

  1. Select the project object in the Navigator.
  2. Select the Options tab in the Editor. The Options tab appears.
    Options Tab, Table Generation Options
    Options Tab, Table Generation Options
  3. Complete the fields on the Table Generation defaults on the tab.

Use this table to enter data in the following fields to specify the default export and generation options.

Field Description
Default Primary Key Enter the default name to use when generating primary keys.
Primary Key Search Pattern Enter the default search pattern to use when generating primary keys.


Configuring Table Creator Java Source Options

Using Workbench, you can configure options that apply when you export Java source code that you can use to create database tables.


How to Configure Table Creator Java Source Options Using Workbench

To specify the default Java code generation options, use this procedure:

  1. Select the project object in the Navigator.
  2. Select the Options tab in the Editor. The Options tab appears.
    Options Tab, Table Creator Java Source Options
    Options Tab, Table Creator Java Source Options
  3. Complete the fields on the Table Creator Java Source defaults on the tab.

Use this table to enter data in the following fields to specify the default table creator options.

Field Description
Class Name Base class name to use when generating table's Java source code from the project.
Root Directory Directory for storing the generated source code.


Configuring Project Java Source Code Options

Using Workbench, you can export a project as Java source. You can configure the class name and root directory that Workbench uses when exporting the project to Java source code.

For more information on exporting a project as Java source, see How to Export Project Java Source Using Workbench.


How to Configure Project Java Source Code Options Using Workbench

To specify the default Java code generation options, use this procedure:

  1. Select the project object in the Navigator.
  2. Select the Options tab in the Editor. The Options tab appears.
    Options Tab, Project Java Source Options
    Options Tab, Project Java Source Options
  3. Complete the fields on the Project Java Source defaults on the tab.

Use this table to enter data in the following fields to specify the default export and generation options:

Field Description
Class Name Base class name to use when generating Java source code from the project.
Root Directory Directory for storing the generated source code.




Copyright Statement

Back to the top