开发者

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=t开发者_运维知识库rue)"/>

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.


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


I discovered, that the order of the columns isn't guaranteed, even if you execute the mapping tool for the same schema another time. I'm also working with IBM DB2 and here I have to be sure that the tables are created exactly the same in every instance. So I generated the DDL script once with the mapping tool and I'm only updating it if I do have changes in my data model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜