Understanding EclipseLink, 2.4
  Go To Table Of Contents
 Search
 PDF

About Metadata

The EclipseLink metadata is the bridge between the development of an application and its deployed run-time environment. Capture the metadata using the following:

The metadata lets you pass configuration information into the run-time environment. The run-time environment uses the information in conjunction with the persistent classes (Java objects or entities) and the code written with the EclipseLink API, to complete the application.

For more information, see "Overriding and Merging" in Java Persistence API (JPA) Extensions Reference for EclipseLink.

Figure 3-2 EclipseLink Metadata

Description of Figure 3-2 follows
Description of "Figure 3-2 EclipseLink Metadata"

This section describes the following:

Advantages of the Metadata Architecture

The EclipseLink metadata architecture provides many important benefits, including the following:

  • Stores mapping information in XML—not in the domain model objects

  • By using the metadata, EclipseLink does not intrude in the object model or the database schema

  • Allows you to design the object model as needed, without forcing any specific design

  • Allows DBAs to design the database as needed, without forcing any specific design

  • Does not rely on code-generation (which can cause serious design, implementation, and maintenance issues)

  • Is unobtrusive: adapts to the object model and database schema, rather than requiring you to design their object model or database schema to suit EclipseLink

Using EclipseLink JPA, you have the flexibility of expressing persistence metadata using standard JPA annotations, deployment XML, or both and you can optionally take advantage of EclipseLink JPA annotation and persistence.xml property extensions.

Creating Project Metadata

A project contains the mapping metadata that the EclipseLink runtime uses to map objects to a data source. The project is the primary object used by the EclipseLink runtime.

This section describes the principal contents of project metadata, including the following:

For Object-relational mapping, the EclipseLink runtime constructs an in-memory project based on any combination of JPA annotations, persistence.xml, orm.xml, and EclipseLink JPA annotation and persistence.xml property extensions.

For Object-XML mapping, the EclipseLink runtime uses a combination of JAXB annotations and eclipselink-oxm bindings. See "Overriding and Merging" in Java Persistence API (JPA) Extensions Reference for EclipseLink.

Descriptors and Mappings

EclipseLink maps persistent entities to the database in the application, using the descriptors and mappings you build with JDeveloper. These tools support several approaches to project development, including the following:

  • Importing classes and tables for mapping

  • Importing classes and generating tables and mappings

  • Importing tables and generating classes and mappings

  • Creating both class and table definitions

The most common solution is to develop the persistent entities using a development tool, such as a modeling tool or an integrated development environment (IDE) like JDeveloper, and to develop the relational model through appropriate relational design tools. You then use JDeveloper to construct mappings that relate these two models.

Although JDeveloper offers the ability to generate persistent entities or the relational model components for an application, these utilities are intended only to assist in rapid initial development strategies–not complete round-trip application development.

For more information, see Chapter 6, "Understanding Descriptors" and Chapter 7, "Understanding Mappings".

Data Source Login Information

For POJO projects, you configure a session login in the session metadata that specifies the information required to access the data source.

For more information, see Creating Session Metadata.

Creating Session Metadata

A EclipseLink session contains the information required to access the data source. The session is the primary object used by your application to access the features of the EclipseLink runtime.

Using EclipseLink JPA, the EclipseLink runtime constructs an in-memory session based on any combination of JPA annotations, persistence.xml, orm.xml, and EclipseLink JPA annotation and persistence.xml property extensions. The use of a sessions.xml file is optional. See "Overriding and Merging" in Java Persistence API (JPA) Extensions Reference for EclipseLink.