【问题标题】:How to use play framework 2.4 evolutions?如何使用play framework 2.4 evolutions?
【发布时间】:2015-10-02 06:29:57
【问题描述】:

我已阅读有关进化的文档,但 Play framework 2.4 进化在我的项目中不起作用。没有出现要求确认 sql 脚本的消息,我无法创建脚本。我的模型,班级用户:

@Entity
@Table(name = "account")
public class User extends Model {
@Id
@Constraints.Required
@GeneratedValue(strategy = GenerationType.AUTO)
private String email;

@Constraints.Required
private String password;

@Constraints.Required
private String firstName;

@Constraints.Required
private String lastName;

@Constraints.Required
private String phone;

@ManyToOne
private Group group;
}

班级组:

@Entity
@Table(name = "group")
public class Group extends Model {

@Id
@Constraints.Required
@GeneratedValue(strategy = GenerationType.AUTO)
public String name;

@OneToMany(mappedBy = "group")
public List<User> users = new ArrayList<>();
}

我已将此添加到 build.sbt:

libraryDependencies ++= Seq(
evolutions,
javaJdbc,
cache,
javaWs,
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41"
)

这个到 application.conf:

# Ebean
ebean.default = ["models.*"]
# Evolutions
# ~~~~~
# You can disable evolutions if needed
play.evolutions.enabled=true
play.evolutions.autoApply=true

我的错误在哪里?

【问题讨论】:

  • 如果我想向数据库添加一个组,我会得到一个异常:IllegalArgumentException: Was Expecting an EntityBean but got a class model.Group

标签: java playframework playframework-2.4


【解决方案1】:

不要称您的实体为“用户”,这很容易出错(许多数据库将其用于元数据)

【讨论】:

  • 谢谢。我重命名了实体。
【解决方案2】:

我已经解决了这个问题。我在 models 上的包 model

【讨论】:

    猜你喜欢
    • 2015-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多