Martin Taal's Blog

About EMF, Teneo, CDO, Texo, Hibernate, Open-Source ERP and other topics

Archive for October 2011

Texo: generate JPA annotated pojos from ecore/xsd

with 4 comments

On request of a user who is using Texo with Vaadin, I spent some time on adding JPA annotation generation to Texo. It was already possible to generate an orm.xml (from an ecore model) using Texo but somehow Vaadin needed annotated classes to work with their JPAContainer.

There are several solutions out there for generating JPA annotated code (Dali and Hibernate Tools for example). So what are the advantages of using Texo over other solutions? Well here are a few:

  • generated code can be changed manually, regeneration will not remove manual code, Texo supports the same pattern as EMF
  • JPA/code generation can be controlled in detail
  • possible to generate JPA annotated code from a XSD
  • access to EMF-like functionality like XML/XMI serialization and runtime model-driven development
  • easy to adapt code generation templates or generate additional code

Now let’s see how JPA annotated code can be generated from an ecore/xsd, it is actually quite easy….

  1. First install Texo from the update site here.
  2. Then right click on an ecore/xsd file and then in the Texo submenu click ‘Generate JPA Annotated Model Code’

Generate JPA Annotated Code

As a default the generated source code will be present in the src-gen source folder:

Texo Generated JPA Annotated Code

That’s it! You can now persist your generated entities, make manual changes etc. If you need more control over the JPA generation you can annotate the model.

I hope this is enough reason to try out Texo. The JPA generation is quite new (beta) so feel free to give feedback or ask questions on the EMFT newsgroup/forum.

gr. Martin

Written by martintaal

October 26, 2011 at 8:46 am

Posted in Texo