The solution

You must override the setNewInstanceDefaults method and initialize any fields which require defaulting before a new instance is inserted onto the database.

In the example, the initial typeCode of MyNewEntity must be defaulted to "SomeType", and the date range set to start on today's date and no end date specified:

Figure 1. Setting default values on new instances of an entity
/**
   * Defaults:
   * <ul>
   * <li>the type to {@linkplain MYNEWENTITYTYPEEntry#SOMETYPE};
   * and</li>
   * <li>the date range to {@linkplain DateRange#todayOnwards()}.
   * </li>
   * </ul>
   */
  public void setNewInstanceDefaults() {
    setType(MYNEWENTITYTYPEEntry.SOMETYPE);
    setDateRange(DateRange.todayOnwards());
  }
Note: Be sure to include a call to super.setNewInstanceDefaults().

For example, for logically-deleteable entities, this super implementation defaults the recordStatus to "active".

Note that this implementation of new instance defaults calls a new private setter (setDateRange - this setter is not available in the entity API but is local to the entity implementation class. (Recall that you do not want callers of your class to be able to set its dates directly.)

The DateRange class contains the convenience method todayOnwards to return a data range that starts on the current business date and has no end date specified.

Create a skeletal implementation of this private setters - you'll flesh it out later:

Figure 2. Creating a skeletal implementation of a private setter method
public void setDateRange(DateRange value) {
    // TODO Auto-generated method stub
  }