I found the solution: The ID value of the model wasn't being generated by ebean.
Setting the auto_increment on the id field on my mysql database worked.
문제
I have a play framework with a simple Address
model but upon calling ebean's #save() method I get the following errors.
The database is configured correctly I think (I can read models without a problem). My unit tests which run on a in-memory H2 database work fine.
Code:
Address address = new Address(street, postalcode, location);
address.save();
Play output:
[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!
Address class
@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
);
}
해결책
I found the solution: The ID value of the model wasn't being generated by ebean.
Setting the auto_increment on the id field on my mysql database worked.