Home >Java >javaTutorial >Why are my JPA-generated table columns in alphabetical order?
Misordering in JPA-Generated Tables
When generating tables using JPA, you may encounter situations where the column ordering differs from your expectations. Specifically, Hibernate will typically generate columns in alphabetical order.
Cause of Misordering
According to a Hibernate developer, the alphabetical ordering is implemented to ensure deterministic ordering across clusters. This behavior change occurred between Hibernate versions 3.2.0 GA and 3.2.1 GA.
Workaround
Unfortunately, there is no official fix for this issue. However, you can implement a workaround by naming your columns in a way that forces the desired ordering. For example, if you want the following column order:
id organizationNumber name
You could name your columns as follows:
a_id b_organizationNumber c_name
This naming convention will ensure that Hibernate generates the columns in the correct order.
The above is the detailed content of Why are my JPA-generated table columns in alphabetical order?. For more information, please follow other related articles on the PHP Chinese website!