Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Texo/Dao

< Texo
Revision as of 07:47, 23 September 2011 by Mtaal.springsite.com (Talk | contribs)

Introduction

This page is under construction

Texo supports the generation of Dao classes which implement common Dao functions such as remove and cross referencing. Dao classes can be generated by right clicking on one or model files and selecting the 'Generate Model + Dao code' option.


Org.eclipse.emf.texo.dao.menu.option.png


As a default the DAO classes will be generated in a separate package inside the package containing the model code.

You can control the Dao code generation with several annotations. The generated Dao code can be changed manually, in the same way as standard EMF/Texo code.

The following sections describe in more detail how to control code generation and how to work with the Dao classes at runtime.

Required Jar files/Plugins

The Texo Dao classes are defined in the org.eclipse.emf.texo.server plugin which is part of the Texo runtime feature (see Download & Install).

So when generating Dao classes make sure to also download the server plugin/jar file to resolve the dependencies.

Annotation properties to control Dao Generation

Dao generation can be controlled through a number of annotation properties on EPackage level.


Org.eclipse.emf.texo.dao.annotations.png


  • Dao Classes Package Path: the package name of the package in which the dao classes should be generated. As a default the model package is used with the dao pattern name appended.
  • Dao Pattern Name: with the introduction of jpa a discussion has started if the word DAO is a correct term or that it should be replaced with the word Manager. This property allows you to control the suffix of the generated classes and of the package used for the dao classes.
  • Dao Root Class: the generated Dao classes will inherit from the org.eclipse.emf.texo.server.dao.BaseDao class, this property allows you to set the baseclass. This makes it possible to easily implement generic functionality for all generated Dao's, the root class should extend the BaseDao class.

The base Dao and Generic Dao

All generated classes inherit from the org.eclipse.emf.texo.server.dao.BaseDao class.

Adding generic functionality to all generated Dao classes

Getting a Dao instance

Common Dao Methods: delete, cross referencing, findBy, get

EntityManager handling

The EntityManagerProvider

The Dao classes make use of the EntityManagerProvider which is the central provider of EntityManager instances for the..

Cross Reference Queries

The ObjectStore allows you to retrieve all the objects which reference a certain target object:

// get maximum 3 referers and include containment referers
List<Object> referers = objectStore.getReferingObjects(target, 3, true);

See the ObjectStore getReferingObjects api and the isReferenced method.

Back to the top