play creates tables with the fields sorted alphabetically
I am using a 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, t开发者_如何转开发he table created by Play! has fields sorted alphabetically like:
id
email
fullname
isAdmin
password
Is there any way to have it in the right order?
Play uses Hibernate. Hibernate orders the columns when it creates the tables. See this discussion:
It is sorted to ensurce deterministic ordering across clusters.
To get a different order, let Hibernate create the DDLs for the tables and sort the columns the way you like.
That is: Don't let Play/Hibernate create the tables automatically. Instead, create them manually.
精彩评论