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 "EclipseLink/Features/JPA"

(Relational Descriptor)
(Sequencing Policies)
Line 57: Line 57:
 
=== Sequencing Policies ===
 
=== Sequencing Policies ===
  
 +
EclipseLink allows multiple sequences to be defined which are used to generate sequence values for new objects.
  
 +
* Native Sequencing
 +
 +
* Sequence Table
 +
** Single Table with 2 Columns with a row per sequence
 +
** Single Table with 1 Row and 1 Column
 +
 +
* Custom Sequencing Policy
 +
 +
* Pre-allocation offers performance improvements minimizing the number of calls to the database
  
 
=== Aggregate Descriptor ===
 
=== Aggregate Descriptor ===

Revision as of 11:01, 23 January 2008

This page ...

Mapping

Mapping entity classes to relational tables involves configuration of a mapping per persistent field.

For all mapping types there are a common set of options available:

Direct Mappings

Mappings where a single attribute of the entity class is mapped to a column. The DirectToFieldMapping in EclipseLink is equivalent to the @Basic mapping in JPA.

Relationship Mappings

    • OneToOne Mapping (includes ManyToOne)
      • Target Foreign Key
    • OneToMany
    • ManyToMany
      • Bi-directional support
    • AggregateObject: Multiple classes within the same row
      • Nested aggregate object mapping
    • AggregateCollection
    • Direct Collection
    • Direct Map
  • Common Mapping Features
    • Converter
      • Custom
      • Object-Type
      • Type Conversion

Relational Descriptor

A relational descriptor allows the mapping from an entity class to one or more tables. It shares all of the capabilities of the Class Descriptor

  • Single Table Mapping
  • Multi-table Policy:
    • Using primary key fields of the same name (default)
    • Join using a specified foreign key
  • Inheritance

Sequencing Policies

EclipseLink allows multiple sequences to be defined which are used to generate sequence values for new objects.

  • Native Sequencing
  • Sequence Table
    • Single Table with 2 Columns with a row per sequence
    • Single Table with 1 Row and 1 Column
  • Custom Sequencing Policy
  • Pre-allocation offers performance improvements minimizing the number of calls to the database

Aggregate Descriptor

An aggregate descriptor maps a set of columns from a table to a class. An aggregate descriptor is referenced within a parent relational descriptor and thus offers no independent identity for the mapped class.

Primary Key Assignment

  • Sequence Table

Optimistic Locking

A descriptor's optimistic locking policy controls how EclipseLink will use values read from the database during the writes to the row to ensure the row has not been modified by another concurrent writer.

  • Version
    • Numeric
    • Timestamp
  • Fields
    • All
    • Selected
    • Changed

'Note: Pessimistic locking can be configured on a query or by default on the descriptor'

Query Framework

  • Query Types
    • Object Read Queries
      • ReadAllQuery
      • ReadObjectQuery
      • ReportQuery: Data project query including aggregate functions and group-by support
      • DataReadQuery
      • ValueReadQuery
    • Object Write Queries
      • InsertObjectQuery
      • UpdateObjectQuery
      • WriteObjectQuery
      • DeleteObjectQuery
    • Bulk Write Queries
      • UpdateAllQuery
      • DeleteAllQuery

Expression Framework

TopLink’s expression framework allows developers to define search criteria, ordering, batch/join reading, selective read fields, etc. using expressions based on the object model instead of coding the relational schema into the application. This not only provides independence between the two models but also simplifies the Java developers work. The query framework in conjunction with the expressions can define almost any query and can work cooperatively with EJB-QL, SQL, & Stored Procedure queries. Some of the key features include:

    • All comparison operators
    • Transparent join definition (inner & outer joins)
    • Pre-defined and custom inline functions (i.e. UPPER)
    • Sub-selects
    • Complex Ordering
    • Aggregate functions (SUM, MIN, MAX, … - ReportQuery)
    • GROUP BY (ReportQuery)
    • Re-usable expression fragments to control joining behavior
    • Definable batch and join reading to any level (reduces N+1 reading)
  • Native Queries
    • SQL
    • Stored Procedure
  • Query By Example
  • Cursored streams and Scrollable cursor

Transactions

The UnitOfWork feature is an object-level transaction to simplify development of INSERT, UPDATE, and DELETE logic.

  • Session Query API
  • Register API to include objects in TX
  • Thread isolated changes to object graph
  • Deferred writing of changes (minimal TX window possible)
  • Minimal change-set calculation
  • SQL Call Ordering determined by referential integrity rules and minimize deadlock through consistent table access.
  • Commit, Commit and Resume
  • Revert instances and all registered objects
  • Cache merge only on successful TX commit
  • PK Assignment for new objects on demand or at commit
  • Merge API for applying client serialized objects
  • Un-register instances to remove from TX
  • Nested & Parallel UnitOfWork support
  • UnitOfWork begin Early Transaction support

DatabasePlatform

EclipseLink's DatabasePlatform encapsulates database specific behavior. While EclipseLink ships with out of the box and extended support for all of the leading database it is also possible to autho a custom platform or extend an existing platform to add custom behavior. The following are the capabilities defined by a database platform:

  • Field Types: Specifies the mapping from the common Java types to database type names. This is used for schema generation.
  • Native SQL (boolean, default = false): allows the user to select the usage of the default SQL92 dialect or the usage of the platform specific SQL generation.
  • ConversionManager
  • shoudTrimStrings (boolean): Indicates if strings returned form the JDBC result set should be trimed during processing
  • Server time query
  • Batch Writing configuration
    • Mode: Concatenation, JDBC, Native-JDBC
    • Batching size
  • Statement caching size (default = 50): controls the number of statements that will be cached per connection. this configuration is only applicable when using internal connection pooling.
  • Cursor handling
  • Transaction isolation
  • shouldOptimizeDataConversion (boolean, default = false): Allow for driver level data conversion optimization to be disabled, required because some drivers can loose precision.
  • Struct Converters: Allows converters to be set directly on the database platform. This is necessary when the Struct being converted requires the JDBC connection to complete its conversion into a Java type.

Oracle

  • OraclePlatform
    • Object-relational type mappings
    • Native Sequencing (SELECT NEXTVAL FROM DUAL)
    • Stored Procedure
    • Hints
  • Oracle8Platform
    • Hierarchical Queries
    • Custom LOB Support for Oracle JDBC
  • Oracle9Platform
    • Oracle Spatial
  • Oracle10Platform
  • Oracle11Platform
  • TimesTenPlatform

DB2

    • Native SQL Support (BLOB, Date, Timestamp, Time)
    • Custom Operators (UCASE, LCASE, CONCAT)
    • Server Time
    • Ignore no data found/modified exceptions
    • Mainframe JDBC support

Sybase

    • Native Sequencing (@@IDENTITY)
    • Native SQL (BLOB, Date, Timestamp, Time)
    • Stored Procedures
    • Server Time

SQL Server

    • Native Sequencing (@@IDENTITY)
    • Native SQL (BLOB, Date, Timestamp, Time)
    • Stored Procedures
    • Server Time

Informix

    • Native Sequencing ("SELECT DISTINCT(DBINFO('sqlca.sqlerrd1')) FROM systables")
    • Native SQL (Date, Timestamp, Time)
    • Outer Joins

MySQL

Derby

Cloudscape

Performance and Scalability Features

EclipseLink offers numerous performance tuning capabilities that allow a developer to get the optimal performance and scalability characteristics for a specific application.

  • Mapping
    • Indirection: Allows relationships to be lazily loaded form the database
    • Fetch Groups: Allows developer to control when the attributes of a class are loaded
  • Query
    • Batch Reading (optimized SQL generation for data retrieval)
    • Join Reading (optimized SQL generation for data retrieval)
    • Report & Partial Attribute Queries
    • Stored Procedure support
    • In-Memory Querying
  • Transactions (UnitOfWork)
    • Minimal change-sets: Only modify what has changed
    • Batch Writing
      • SQL Concatenation
      • JDBC batch writing
      • Native JDBC batching
    • Bulk Operations
      • Bulk Update: Issue a single query to update the database and invalidate cached objects effected
      • Bulk Delete
  • JDBC
    • Prepared Statement Caching (when using EclipseLink's connection pooling)
    • Parameter Binding (Strings, LOBs, or ALL)
  • Sequence pre-allocation: Reduce quaqntity of database calls by retrieving PK chunks

Back to the top