Column ordering in DDL generation

Hi

I’m working on a project where we driver our data model through DDL generation through JPA annotations. So far, this has worked impressively fine. We can generate DDL for various databases and test a lot of cross-database portability stuff quite easily with test-containers.

One thing that annoys me a little too much is the order columns are generated. I did a bit of googling and found a few posts about it (like java - How to maintain the column order when creating a new table using hibernate? - Stack Overflow).

I thought about taking a stab at implementing it myself (perhaps with a custom annotation used to sort the column list before iteration over the columns during DDL generation and with a property that enables the feature. Or perhaps if possible just retain the field order in the java file).

But the codebase is BIG and I would love to hear the team’s opinion about if it would stand a chance to get accepted and perhaps a few pointers on how you would prefer it to be implemented.

Best regards Jens

Hi Jens,

not sure if you can view this (Trello) but I was thinking about this as well especially because due to alignment, it makes a difference on PostgreSQL in which order the columns are defined. I created a discussion for this where I would like to invite you to participate in: Column ordering SPI and annotations support for static ordering · Discussion #3989 · hibernate/hibernate-orm · GitHub