entity application model diagram

The EntityApplicationModel class serves as the base for the application. Its main purpose is to hold references to the root EntityModel instances used by the application.

When extending this class you must provide a constructor with a single EntityConnectionProvider parameter, as seen below.

public class StoreApplicationModel extends SwingEntityApplicationModel {

  public StoreApplicationModel(EntityConnectionProvider connectionProvider) {
    super(connectionProvider, List.of(createCustomerModel(connectionProvider)));
  }

  private static SwingEntityModel createCustomerModel(EntityConnectionProvider connectionProvider) {
    CustomerModel customerModel =
            new CustomerModel(connectionProvider);
    CustomerAddressModel customerAddressModel =
            new CustomerAddressModel(connectionProvider);

    customerModel.detailModels().add(customerAddressModel);

    //populate the model with rows from the database
    customerModel.tableModel().items().refresh();

    return customerModel;
  }
}