Related: Trouble Shooting


We can use @MappedSuperclass for common properties used across many entity beans.

It is common to have a mapped superclass with @Id, @Version and @WhenModified properties like:

package org.example.domain;

import io.ebean.Model;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.time.Instant;

 * Base domain object with Id, version, whenCreated and whenModified.
public abstract class BaseDomain {

  long id;

  Long version;

  Instant whenCreated;

  Instant whenModified;

  // getters and setters


Our entity beans then extend this to inherit the common properties.

Customer extends BaseDomain

public class Customer extends BaseDomain {

  String name;

  LocalDate registered;

Order extends BaseDomain

public class Order extends BaseDomain {

  Customer customer;

  LocalDate orderDate;

Edit Page