Using JPA, order of database columns are reverse of how they appear in XML metadata!

Description

It's important to have control over the order columns of each generated table. In the past, I used Hibernate native, now I upgrated to JPA to maintain compatibility with Cloud systems. With Hibernate native, the order of the column was the same as they appear in the XML metadata.

However with JPA, it's a different story. The order of the generated columns is the reverse of how they appear in the JPA XML metadata. That's not right if you are trying interface with legacy systems and the database system is made up on legacy databases.

My bug report has two aspects to it.

1) First spact is that the JPA XML schema (http://java.sun.com/xml/ns/persistence/orm_2_0.xsd) is not flexible and has strict rules as to how to order elements inside a Java class. For instance: The attributes always come first followed by associations. In other word they used SEQUENCE in the schema instead of using ALTERNATIVES.

This apparent error is part of the standard and not the fault of the Hibernate.

2) Second aspect is that even within attributes in the XML metadata, the order is not respected. In fact it is reversed to what is specified in the XML metadata file, which is very strange. That's a definitely an error from Hibernate and should be fixed.

Environment

Testing with Windows 7 but this bug should appear everywhere.

Assignee

Unassigned

Reporter

Colbert Philippe

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Priority

Minor
Configure