How to order columns in Spring Data JPA

Viewed 1854

I have the below class:

@Table(name = "Code_Master")
public class CodeMaster {

    @Column(name = "Grade")
    private String grade;

    @Column(name = "Code")
    private Integer code;

    @Column(name = "Code_Name")
    private String codeName;

    @Column(name = "Company")
    private Integer company;

    @Column(name = "Case")
    private Integer case;
}

This generates my table in Database with sorted column names, in the order:
case
code
codeName
company
grade

However, I do not want this order. I want the column order that is specified in the class.

I have searched throught, but could not find a way to change the create table query of spring data jpa.

Resources tried:
Wrong ordering in generated table in jpa
https://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-creating-database-queries-with-the-query-annotation/
https://www.baeldung.com/spring-data-jpa-generate-db-schema
https://thorben-janssen.com/create-generate-table-model/

Can someone please help me with this issue?

0 Answers
Related