views:

392

answers:

1

I am using openjpa runtime of JPA specification. At development time I am using annotations to configure jpa entities. At Integration, Pre-Production and and Production environment, I am using orm mapping files to configure entities. Please suggest a tool which can generate mapping files from jpa annotations, so that these mapping files can be manually edited for different environment. If there is already a opensource maven-plugin; will be great.

+1  A: 

I don't really know OpenJPA so there is maybe a better way to do this but one option would be to first generate the XML schema file from annotated entities using the Schema Tool and then the orm.xml file from the schema.xml using the Reverse Mapping Tool. Actually, this process is discussed in this thread.

I've checked the OpenJPA Maven Plugin but it doesn't seem to support the Reverse Mapping part (it only has a openjpa:schema goal that allows to Create a file which contains the schema mapping XML, the first required operation, but nothing for the second part). Extending the plugin to add the missing openjpa:reverse-mapping goal would thus require some development but it shouldn't be an hard task.

There is another option though. OpenJPA provides the following Ant tasks for both operations:

So it should be possible to call them from Maven using the Maven AntRun Plugin. Check the documentation for more details on how to use them.

Pascal Thivent
Thanks Pascal, I will try this proposed solution.
Digambar Daund