Jump to: navigation, search

Teneo/Hibernate/Dynamic EMF Tutorial

< Teneo‎ | Hibernate
Revision as of 03:18, 3 March 2010 by Mtaal.elver.org (Talk | contribs) (Before starting this tutorial)

EMF allows you to dynamically change the in-memory ecore model by adding EPackages, EClasses and EStructuralFeatures. Teneo supports persisting dynamically created models. It is for example possible to read an ecore model from an ecore file (without generating code) and create the relational database schema. There are however some (practical) limitations, see the last section on this page.

The source code of this tutorial is available in the example project which you can download here.

This tutorial assumes some basic knowledge of EMF. If you are new to EMF then it can make sense to first try one of the core EMF tutorials which you can find here.

Before starting this tutorial

Before starting this tutorial there are a number of things which you need to take into account:

  • It uses the QuickStart tutorial class described in the quick start tutorial to create a database for the Library example and some content.
  • The initial setup of the quick start tutorial also applies here.
  • When using a non-in-memory database: the tutorial assumes that there is an empty database with the name DynamicLibrary. When you rerun this tutorial you should make sure that this database is empty again (otherwise one of the smaller tests in the tutorial will fail).
  • In this tutorial the Library example is extended with two new types: SchoolBook (which inherits from Book) and Course which refers to a SchoolBook.


  • It is not possible to create a containment relation between a dynamic model and a static model part. With static we mean the model for which java code has been generated.
  • When the model is dynamically changed it is required to update the database schema. To change the database schema database servers can lock the whole database. This is probably not practical in a live production environment.
  • A dynamic EClass can not have a composite-id.