How to order columns alphabetically when creating a database table with Hibernate


#1

Hi,

Hibernate does not respect my Java Class fields order. He tries to create a physical table order my class fields alphabetically. Is there any option available to avoid doing that? I want to force the order of my Java Class.

Thanks in advance


#2

The Hibernate User Guide clearly states that:

Although the automatic schema generation is very useful for testing and prototyping purposes, in a production environment, it’s much more flexible to manage the schema using incremental migration scripts.

Therefore, you are better off using an incremental migration script tool like Flyway and have absolute control over the database table structure.


#3

Thanks Vlad, I will take a look into that.