Related: Trouble Shooting

Model

We can have our entity beans extend io.ebean.Model. They then have save() and delete() methods.

BaseDomain extends Model ...

import io.ebean.Model;
...

@MappedSuperclass
public abstract class BaseDomain extends Model {

  ...

}

Now we can just save() and delete() them:

Model.save()

Customer customer = new Customer("Jack");

// just save the bean
customer.save();


// and delete it ...
customer.delete();

Note that Model.save() and Model.delete() use the default server. We obtain the default server via Ebean.getDefaultServer().

Model vs Repository

We don't have to use Model and the common alternative is to use the repository pattern where we create a Repository for each entity type - e.g. CustomerRepository for the Customer entity bean and OrderRepository for the Order entity bean and so forth.

The recommended approach is to use Model and Finder rather than the Repository pattern. For more details goto ... TODO

Edit Page