Override the modify method (if required)

If you require logic to prevent modifications to the entity if it is in an inappropriate state, then you must override your entity's modify method:

Figure 1. Overriding the modify method
/**
   * {@inheritDoc}
   */
  @Override
  public void modify(Integer versionNo)
    throws InformationalException {

    if (!getState().isModifyAllowed()) {
      ValidationHelper
          .addValidationError(
"You are not allowed to modify this record when it is in this state"
);
    }

    super.modify(versionNo);
  }
Note: Only explicit calls to your entity's modify method (e.g. through its interface) will hit this logic - state transitions will typically call super.modify directly and thus bypass this logic.