开发者

play creates tables with the fields sorted alphabetically

开发者 https://www.devze.com 2023-03-11 04:54 出处:网络
I am using a model in Play like this: package models; import java.util.*; import javax.persistence.*; import play.db.jpa.*;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消