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

Difference between revisions of "Texo/Generate JPA-ORM Introduction"

(Generating JPA annotated model code)
 
(8 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
== Introduction ==
 
== Introduction ==
  
With Texo you can generate an orm.xml directly from an ecore model. The orm.xml can be used to configure the persistence layer.  
+
With Texo you can generate JPA annotated code or an orm.xml directly from an ecore model. Texo supports the [[JPA]] ORM 2.0 standard. The orm.xml can be used to configure the persistence layer.  
  
Texo uses EclipseLink for its testing. See here for more information on using EclipseLink and configuring EclipseLink:
+
Texo uses [[EclipseLink]] for its testing. See [[EclipseLink/UserGuide|EclipseLink User Guide]] for more information on using and configuring EclipseLink.
http://wiki.eclipse.org/EclipseLink/UserGuide
+
  
The generated orm.xml refers to the classes/java members/types as generated by Texo code generation (so taking into account any model generate annotations you have specified).
+
The generated '''orm.xml''' refers to the classes/java members/types as generated by Texo code generation (so taking into account any model generate annotations you have specified).
  
When generating the orm.xml Texo tries to make use of the default capabilities of the ORM layer. This means that only the necessary decisions (for example naming) are made by Texo. You can override/extend the generated orm.xml by specifying [[Texo/ORM_JPA_Annotations_Details|ORM annotations on the model]]. This is done in the same way as with the code generation annotations. For more information on annotations models, see [[Texo/Code_Generation_Details|here]].
+
When generating the orm.xml Texo tries to make use of the default capabilities of the ORM layer. This means that only the necessary decisions (for example naming) are made by Texo. You can override/extend the generated orm.xml by specifying [[Texo/ORM_JPA_Annotations_Details|ORM annotations on the model]]. This is done in the same way as with the code generation annotations. For more information on annotations models, see [[Texo/Code_Generation_Details|Texo Code Generation details]].
 +
 
 +
== Generating JPA annotated model code ==
 +
 
 +
Right click on an ecore/xsd file and then in the Texo submenu click 'Generate JPA Annotated Model Code'
 +
 
 +
 
 +
[[Image:org.eclipse.emf.texo.generate.jpacode.png|center|700px]]
 +
 
 +
 
 +
The JPA annotations will be present in the source code.
 +
 
 +
 
 +
[[Image:org.eclipse.emf.texo.generate.jpacode.source.png|center|700px]]
  
 
== Generating an orm.xml ==
 
== Generating an orm.xml ==
Line 21: Line 33:
  
 
The orm.xml will be created in the same folder as the ecore file which was selected. ''Any existing orm.xml in that same folder will be overwritten''.
 
The orm.xml will be created in the same folder as the ecore file which was selected. ''Any existing orm.xml in that same folder will be overwritten''.
 +
 +
This pages shows how you can create an orm.xml directly from an ecore model. Often it makes sense to tweak or change the ORM mapping. This can be done using annotations on the model, or in other words an ORM annotation model, see [[Texo/ORM_JPA_Annotations_Details|here]] for more information on this.

Latest revision as of 05:14, 26 October 2011

Introduction

With Texo you can generate JPA annotated code or an orm.xml directly from an ecore model. Texo supports the JPA ORM 2.0 standard. The orm.xml can be used to configure the persistence layer.

Texo uses EclipseLink for its testing. See EclipseLink User Guide for more information on using and configuring EclipseLink.

The generated orm.xml refers to the classes/java members/types as generated by Texo code generation (so taking into account any model generate annotations you have specified).

When generating the orm.xml Texo tries to make use of the default capabilities of the ORM layer. This means that only the necessary decisions (for example naming) are made by Texo. You can override/extend the generated orm.xml by specifying ORM annotations on the model. This is done in the same way as with the code generation annotations. For more information on annotations models, see Texo Code Generation details.

Generating JPA annotated model code

Right click on an ecore/xsd file and then in the Texo submenu click 'Generate JPA Annotated Model Code'


Org.eclipse.emf.texo.generate.jpacode.png


The JPA annotations will be present in the source code.


Org.eclipse.emf.texo.generate.jpacode.source.png

Generating an orm.xml

It is quite easy to generate an orm.xml from a model: right-click on the ecore model and select Texo > Generate


Org.eclipse.emf.texo.generate.orm.png


The orm.xml will be created in the same folder as the ecore file which was selected. Any existing orm.xml in that same folder will be overwritten.

This pages shows how you can create an orm.xml directly from an ecore model. Often it makes sense to tweak or change the ORM mapping. This can be done using annotations on the model, or in other words an ORM annotation model, see here for more information on this.

Back to the top