Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Teneo/Hibernate/Architecture Overview
The EMF - Hibernate integration consists of two main parts:
- Mapping: the mapping layer is responsible for the automatic mapping of an EMF model to an in-memory Hibernate mapping. The mapping logic can be influenced by EJB3-like annotations in the model.
- Runtime: the runtime layer takes care of handling specific EMF features such as lazy loading of ELists, setting EFeatures from the database, instantiating EObjects using the EClass name, etc.
Teneo Mapping Overview
The image below illustrates the basic process from a set of EPackages or an ecore file to the Teneo runtime. The starting point is the EMF model represented by one or more EPackages. These EPackages can contain EJB3-like annotations.
The application starts up and registers the EPackages in Teneo. The registered EPackages (and their EAnnotations) are translated to an in-memory annotated model. This annotated model initially only contains the annotations which have been specified manually as EAnnotations in the original model.
In the next step Teneo automatically adds annotations to map the EMF model to an or representation. The manually entered EAnnotations are retained and not overwritten.
The model is now fully annotated and translated into an in-memory hibernate.hbm.xml String. This Hibernate mapping is then used to configure a HbDataStore.
Runtime Layer
The main visible component of the runtime layer is the HbDataStore. The HbDataStore controls a SessionFactory and a set of EPackages which are persisted using the sessions of this session factory. When using a Hibernate session, behind the scenes Teneo takes care of instantiating EMF objects and setting/getting EFeatures from the database. Teneo also handles lazy loading of ELists.
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.