Search code examples
jpa-2.0openjpa

OpenJPA forward mapping tool order column specification during table creation


We've set the following property in persistence.xml:

<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

If I understand correctly, this is what tells the OpenJPA MappingTool that it should generate appropriate tables in database, should those not be found for corresponding managed entities.

What I have failed to figure out is whether there is any way to specify the ordering of columns which MappingTool persists once it gets hold of reference to EntityManager?

MappingDefaults doesn't provide for such a property (at least I couldn't find it) and practically the only way to do this is to re-implement a part of OpenJPA API in order to support this.

That option is currently not feasible for us and I would ask for any idea or guideline on how to specify column ordering - if any.

Our environment consists of the following stack:

  • OpenJPA 2.0.1
  • JDK 1.6.23
  • Spring 3.0.5
  • Maven 2.2.1
  • IBM DB2 9.7 Express-C

I am also a bit surprised that there only a handful of such questions on Google.


Solution

  • If the order of columns for a particular table matter for your application, don't use SynchronizeMappings.