Play creates tables with fields sorted alphabetically

I use the model in Play like this:

package models;

import java.util.*;
import javax.persistence.*;

import play.db.jpa.*;

@Entity
public class User extends Model {

    public String email;
    public String password;
    public String fullname;
    public boolean isAdmin;

    public User(String email, String password, String fullname) {
        this.email = email;
        this.password = password;
        this.fullname = fullname;
    }

}

Then the table created in Play! fields are sorted alphabetically:

id
email
fullname
isAdmin
password

Is there a way to get it in the correct order?

+3
source share
1 answer

Play uses Hibernate. Hibernate orders columns when creating tables. See this discussion :

It is sorted to provide deterministic cluster ordering.

To get a different order, let Hibernate create DDL for the tables and sort the columns as you like.

That is: Do not let Play / Hibernate automatically create tables. Instead, create them manually.

+8
source

All Articles