HomeEMF HibernateEMF JDO/JPOXWeb App GenerationServices
 

EMF - JPOX Integration Overview

The EMF - JPOX Persistency solution consists of two tools:

  1. EMF - JPOX OR Mapper: generates object-relational mapping files from ecore model.
  2. EMF - JPOX Runtime: takes care of handling EMF specific things such as EMF collections, containment and bi-directional relations.

These tools are used in the development process in the following way:

Generate OR Mapping file

After the java sources have been generated from the ecore model, the next step is to generate the package.jdo file. The package.jdo file describes for a object relational mapping tool how to persist java objects to relational tables.

The EMF - JPOX OR Mapper Tool performs this task.

Class Enhancement

In a jdo 2.0 scenario java classes are enhanced on the basis of the package.jdo file. The enhancement uses byte-code enhancement tools to adapt compiled java classes. During the enhancement action, persistent related interfaces and functionality are added to the java classes.

JPOX delivers an Eclipse plugin which can be used to automatically enhance the java classes after each Eclipse build.

Runtime Layer

The java classes have been enhanced and ready to be persisted. EMF objects require specific handling in relation to jpox. This is mainly related to the way EMF handles references and collections. Also the EMF resource approach requires specific jpox implementations. To handle the EMF specifics, the EMF - JPOX runtime layer was developed. This layer is very small (about 50kb) but is essential to get a working EMF - JPOX integration.

The main visible component of the runtime layer is the JpoxDataStore. The JpoxDataStore controls a PersistenceManagerFactory and a set of EPackages which are persisted using the PersistenceManagers of this PersistenceManagerFactory. When using a PersistenceManager, behind the scenes Teneo takes care of instantiating EMF objects and setting/getting EFeatures from the database. Teneo also handles lazy loading of ELists.

Teneo Runtime Layer

EJB3 Annotations

Teneo can automatically map the EMF model to an object relational representation. However there are situations in which it makes sense to influence or control the mapping. For this purpose Teneo supports EJB3-like annotations in the model. The annotations can be used to control the way the inheritance structure is mapped to the relational store or how efeatures are mapped to database columns. For a complete overview of the supported EJB3 annotations see here.

The EJB3 support has been developed in such a way that it is only required to specify annotations for those parts of the model for which the automatic behavior does not result in the required behavior. For example it is possible to specify a column annotation for one efeature in a model while all other efeatures and eclasses are automatically handled by Teneo.

EJB3 annotations are defined in EAnnotations in a specific format. See here for more information.