Java Playframework Ebean.Save()使连接关闭

Java Playframework Ebean.Save()使连接关闭,java,playframework,playframework-2.2,ebean,Java,Playframework,Playframework 2.2,Ebean,我有一个play框架,它有一个简单的地址模型,但是在调用ebean的#save()方法时,我得到了以下错误 我认为数据库配置正确(我可以毫无问题地读取模型)。 我在内存H2数据库上运行的单元测试工作正常 代码: 播放输出: [error] c.j.b.ConnectionHandle - Database access problem. Killing off this connection and all remaining connections in the connection pool

我有一个play框架,它有一个简单的
地址
模型,但是在调用ebean的#save()方法时,我得到了以下错误

我认为数据库配置正确(我可以毫无问题地读取模型)。 我在内存H2数据库上运行的单元测试工作正常

代码:

播放输出:

[error] c.j.b.ConnectionHandle - Database access problem. Killing off this connection and all remaining connections in the connection pool. SQL State = HY000
[error] play - Cannot invoke the action, eventually got an error: javax.persistence.PersistenceException: java.sql.SQLException: Connection is closed!
地址类

@Entity
public class Address extends Model {
@Id
    public int id;
    public String postalcode;
    public String street;
    public String location;

    @OneToMany(cascade= CascadeType.ALL)
    public List<Estate> estates;

    public Address(String street, String postalcode, String location){
        this.postalcode = postalcode;
        this.street = street;
        this.location = location;
    }
    public Address(int id, String street, String postalcode, String location){
        this.id = id;
        this.postalcode = postalcode;
        this.street = street;
        this.location = location;
    }
    public static Finder<Integer,Address> find = new Finder<Integer, Address>(
        Integer.class, Address.class
    );
}
@实体
公共类地址扩展模型{
@身份证
公共int id;
公共字符串后代码;
公众街;;
公共字符串位置;
@OneToMany(级联=级联类型.ALL)
公屋;;
公共广播(字符串街道、字符串邮政编码、字符串位置){
this.postalcode=postalcode;
这条街;
这个位置=位置;
}
公共地址(int-id、String-street、String-postalcode、String-location){
this.id=id;
this.postalcode=postalcode;
这条街;
这个位置=位置;
}
公共静态查找器find=新查找器(
Integer.class,Address.class
);
}

我找到了解决方案:模型的ID值不是由ebean生成的

在mysql数据库的id字段上设置auto_increment有效

@Entity
public class Address extends Model {
@Id
    public int id;
    public String postalcode;
    public String street;
    public String location;

    @OneToMany(cascade= CascadeType.ALL)
    public List<Estate> estates;

    public Address(String street, String postalcode, String location){
        this.postalcode = postalcode;
        this.street = street;
        this.location = location;
    }
    public Address(int id, String street, String postalcode, String location){
        this.id = id;
        this.postalcode = postalcode;
        this.street = street;
        this.location = location;
    }
    public static Finder<Integer,Address> find = new Finder<Integer, Address>(
        Integer.class, Address.class
    );
}