Column order on OpenJPA

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

I am using the ant bind task to create DDL for my classes in sql file.

+6
source share
1 answer

No, each JPA implementation can arrange the columns in the generated DDL in the order that it sees fit, and in general the programmer has no control over this - for example: Hibernate uses alphabetically , but DataNucleus allows you to specify the position of the column due to non-standard annotation. Unfortunately, OpenJPA does not provide a mechanism for specifying the order of columns.

I had a similar problem a while ago, my client database recommendations introduced certain orders in columns, and my JPA provider issued a different order. Decision? we wrote textual processing of a Java program, which, taking into account the generated DDL as input, reordered the columns in the code so that it complied with the recommendations and produced a new file with the modified DDL as output; the program was launched from the Ant task. Not very, but from a practical point of view, it was the best solution we could put together.

+6
source

Source: https://habr.com/ru/post/946545/


All Articles