OpenJPA上的列顺序 [英] Column order on OpenJPA

查看:79
本文介绍了OpenJPA上的列顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以按顺序获取列 在Java类中声明,还是以其他方式指定顺序?

Is there a way to get the columns in the order they are declared in the Java class, or to specify the order in some other way?

我正在使用映射工具ant任务在sql文件中为我的类生成DDL.

I'm using the mapping tool ant task to generate the DDL for my classes in a sql file.

推荐答案

否,JPA的每个实现都可以按照自己认为合适的顺序自由排列生成的DDL中的列,并且通常程序员对此没有控制权-例如:Hibernate使用字母顺序,但是DataNucleus允许指定

No, each implementation of JPA is free to arrange the columns in the generated DDL in the order it sees fit, and in general the programmer has no control over this - for example: Hibernate uses alphabetical order, but DataNucleus allows the specification of a column position thanks to a non-standard annotation. Sadly, OpenJPA doesn't provide a mechanism for specifying column ordering.

前段时间我遇到了类似的问题,我的客户的数据库准则要求在列中进行一定的排序,而我的JPA提供程序生成了不同的订单.解决方案?我们编写了一个文本处理Java程序,以生成的DDL作为输入,对代码中的列进行了重新排序,使其符合准则,并以修改后的DDL作为输出生成了新文件;该程序是从Ant任务运行的.虽然不漂亮,但是从实际角度来看,这是我们可以召集的最佳解决方案.

I had a similar problem a while ago, the data base guidelines of my client mandated a certain ordering in the columns and my JPA provider produced a different order. The solution? we wrote a text-processing Java program that, given the generated DDL as input, reordered the columns in the code so it satisfied the guidelines and produced as output a new file with the modified DDL; the program was run from an Ant task. Not pretty, but from a practical standpoint it was the best solution we could muster.

这篇关于OpenJPA上的列顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆