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

Customer extends Model ...

package org.example.domain;

import javax.persistence.Id;
import javax.persistence.Entity;

public class Customer extends Model {

  long id;

  String name;

  // getters and setters
package org.example.domain

import javax.persistence.Entity
import javax.persistence.Id

class Customer : Model() {

  var id: Long = 0

  var name: String? = null


Now we can just save() and delete() customer.

Note that it would be nice if we have a constructor that takes name. We will do that shortly and that means we can make name a non-nullable property.

Customer customer = new Customer();
customer.setName("Hello world");;

val customer = Customer()  = "Hello entity bean"


Note that save() and delete() use the default database. We obtain the default database via DB.getDefault().