JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Application Development Guide
search filter icon
search icon

Document Information


Part I Development Tasks and Tools

1.  Setting Up a Development Environment

2.  Class Loaders

3.  Debugging Applications

Part II Developing Applications and Application Components

4.  Securing Applications

5.  Developing Web Services

6.  Using the Java Persistence API

7.  Developing Web Applications

8.  Using Enterprise JavaBeans Technology

9.  Using Container-Managed Persistence

GlassFish Server Support for CMP

CMP Mapping

Mapping Capabilities

The Mapping Deployment Descriptor File

Mapping Considerations

Join Tables and Relationships

Automatic Primary Key Generation

Fixed Length CHAR Primary Keys

Managed Fields

BLOB Support

CLOB Support

Automatic Schema Generation for CMP

Supported Data Types for CMP

Generation Options for CMP

Schema Capture

Automatic Database Schema Capture

Using the capture-schema Utility

Configuring the CMP Resource

Performance-Related Features

Version Column Consistency Checking

To Use Version Consistency

Relationship Prefetching

Read-Only Beans

Default Fetch Group Flags

Configuring Queries for 1.1 Finders

About JDOQL Queries

Query Filter Expression

Query Parameters

Query Variables

JDOQL Examples

Example 1

Example 2

Example 3

CMP Restrictions and Optimizations

Disabling ORDER BY Validation

Setting the Heap Size on DB2

Eager Loading of Field State

Restrictions on Remote Interfaces

PostgreSQL Case Insensitivity

No Support for lock-when-loaded on Sybase

Sybase Finder Limitation

Date and Time Fields


MySQL Database Restrictions

10.  Developing Java Clients

11.  Developing Connectors

12.  Developing Lifecycle Listeners

13.  Developing OSGi-enabled Java EE Applications

Part III Using Services and APIs

14.  Using the JDBC API for Database Access

15.  Using the Transaction Service

16.  Using the Java Naming and Directory Interface

17.  Using the Java Message Service

18.  Using the JavaMail API


Performance-Related Features

The GlassFish Server provides the following features to enhance performance or allow more fine-grained data checking. These features are supported only for entity beans with container managed persistence.

The following topics are addressed here:

Note - Use of any of these features results in a non-portable application.

Version Column Consistency Checking

The version consistency feature saves the bean state at first transactional access and caches it between transactions. The state is copied from the cache instead of being read from the database. The bean state is verified by primary key and version column values at flush for custom queries (for dirty instances only) and at commit (for clean and dirty instances).

To Use Version Consistency

  1. Create the version column in the primary table.
  2. Give the version column a numeric data type.
  3. Provide appropriate update triggers on the version column.

    These triggers must increment the version column on each update of the specified row.

  4. Specify the version column.

    This is specified in the check-version-of-accessed-instances subelement of the consistency element in the sun-cmp-mappings.xml file. See consistency in Oracle GlassFish Server 3.1 Application Deployment Guide.

  5. Map the CMP bean to an existing schema.

    Automatic schema generation is not supported for beans with version column consistency checking. Instead, work with your database administrator to create the schema and add the required triggers.

Relationship Prefetching

In many cases when an entity bean’s state is fetched from the database, its relationship fields are always accessed in the same transaction. Relationship prefetching saves database round trips by fetching data for an entity bean and those beans referenced by its CMR fields in a single database round trip.

To enable relationship prefetching for a CMR field, use the default subelement of the fetched-with element in the sun-cmp-mappings.xml file. By default, these CMR fields are prefetched whenever findByPrimaryKey or a custom finder is executed for the entity, or when the entity is navigated to from a relationship. (Recursive prefetching is not supported, because it does not usually enhance performance.) See fetched-with in Oracle GlassFish Server 3.1 Application Deployment Guide.

To disable prefetching for specific custom finders, use the prefetch-disabled element in the glassfish-ejb-jar.xml file. See prefetch-disabled in Oracle GlassFish Server 3.1 Application Deployment Guide.

Multilevel relationship prefetching is supported for CMP 2.1 entity beans. To enable multilevel relationship prefetching, set the following property using the asadmin create-jvm-options command:

asadmin create-jvm-options

Read-Only Beans

Another feature that the GlassFish Server provides is the read-only bean, an entity bean that is never modified by an EJB client. Read-only beans avoid database updates completely.

Note - Read-only beans are specific to the GlassFish Server and are not part of the Enterprise JavaBeans Specification, v2.1. Use of this feature for an EJB 2.1 bean results in a non-portable application.

A read-only bean can be used to cache a database entry that is frequently accessed but rarely updated (externally by other beans). When the data that is cached by a read-only bean is updated by another bean, the read-only bean can be notified to refresh its cached data.

The GlassFish Server provides a number of ways by which a read-only bean’s state can be refreshed. By setting the refresh-period-in-seconds element in the glassfish-ejb-jar.xml file and the trans-attribute element (or @TransactionAttribute annotation) in the ejb-jar.xml file, it is easy to configure a read-only bean that is one of the following:

Access to CMR fields of read-only beans is not supported. Deployment will succeed, but an exception will be thrown at runtime if a get or set method is invoked.

Read-only beans are best suited for situations where the underlying data never changes, or changes infrequently. For further information and usage guidelines, see Using Read-Only Beans.