Martin Taal's Blog

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

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

4 Responses

Subscribe to comments with RSS.

  1. Hi, would be possible to do such generation as a part of a maven/tycho build ?


    February 22, 2012 at 5:20 pm

    • I don’t know tycho/maven I am afraid. Texo uses buckminster for the build and during the build annotated java code is generated for test models. Texo needs an eclipse workspace/project to generate the code. It use source code formatter and import organizing settings of the dev project.
      With buckminster, during the build, a complete development eclipse workspace is created which allows all these things. But I am not sure how/if maven/tycho does this.

      gr. Martin


      February 22, 2012 at 7:44 pm

  2. Texo is really cool since it can generate pure pojo which has no dependency on EMF.
    And also can generate JPA annotation!

    Please keep on your good work.

    Oliver Zhou

    February 25, 2012 at 3:16 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: