Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Teneo/Hibernate/Tutorial"

(New page: __TOC__ This tutorial shows how EMF, Teneo and Hibernate work together to automatically create the database schema and persist EMF objects. The tutorial also shows examples of [http://doc...)
 
Line 14: Line 14:
  
 
For mysql and other non-in-memory databases you have to create the database up-front (so not the tables inside the database but just the database itself). For this tutorial the database name should be: library.
 
For mysql and other non-in-memory databases you have to create the database up-front (so not the tables inside the database but just the database itself). For this tutorial the database name should be: library.
 +
 +
== Running the tutorial ==
 +
 +
== Running 'quick start' ==
 +
 +
After downloading the examples project from cvs you can directly run the tutorial. Open the project and navigate to the Tutorial.java file and right click and select 'Run As > Java Application'. You will see several things getting printed to the console (one of them is the generated Hibernate mapping).
 +
 +
This run takes the following steps:
 +
* reads the EPackage model from the generated EPackage file.
 +
* generate a hibernate mapping for the EPackage
 +
* create the database (on hsqldb)
 +
* create objects and persist them
 +
* read the objects back using queries
 +
* make changes, add new objects and persist them
 +
* read and update the objects an EMF Hibernate resource
 +
 +
== Initialization ==

Revision as of 03:38, 3 March 2010

This tutorial shows how EMF, Teneo and Hibernate work together to automatically create the database schema and persist EMF objects. The tutorial also shows examples of HQL queries for EMF object and using the EMF Hibernate resource.

This tutorial uses 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.

Initial Setup

The tutorial assumes that you have a running Eclipse with EMF and Teneo installed. In addition the Teneo dependencies (incl. hsqldb and mysql drivers) should be installed. See the Download & Install page for more information.

This tutorial uses hsqldb but it can easily be changed to use mysql or another database. For other databases than hsqldb and mysql you need to take make sure that the jdbc driver is in the classpath of the org.eclipse.emf.teneo.hibernate.examples project.

For mysql and other non-in-memory databases you have to create the database up-front (so not the tables inside the database but just the database itself). For this tutorial the database name should be: library.

Running the tutorial

Running 'quick start'

After downloading the examples project from cvs you can directly run the tutorial. Open the project and navigate to the Tutorial.java file and right click and select 'Run As > Java Application'. You will see several things getting printed to the console (one of them is the generated Hibernate mapping).

This run takes the following steps:

  • reads the EPackage model from the generated EPackage file.
  • generate a hibernate mapping for the EPackage
  • create the database (on hsqldb)
  • create objects and persist them
  • read the objects back using queries
  • make changes, add new objects and persist them
  • read and update the objects an EMF Hibernate resource

Initialization

Back to the top