Texo: generate JPA annotated pojos from ecore/xsd
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.
- 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….
- First install Texo from the update site here.
- Then right click on an ecore/xsd file and then in the Texo submenu click ‘Generate JPA Annotated Model Code’
As a default the generated source code will be present in the src-gen source folder:
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.