/**
   * INTERNAL: Gets the session which this query will be executed on. Generally will be called
   * immediately before the call is translated, which is immediately before session.executeCall.
   *
   * <p>Since the execution session also knows the correct datasource platform to execute on, it is
   * often used in the mappings where the platform is needed for type conversion, or where calls are
   * translated.
   *
   * <p>Is also the session with the accessor. Will return a ClientSession if it is in transaction
   * and has a write connection.
   *
   * @return a session with a live accessor
   * @param query may store session name or reference class for brokers case
   */
  public AbstractSession getExecutionSession(DatabaseQuery query) {
    AbstractSession sessionByQuery = getSessionForQuery(query);

    // Always forward to a registered session.
    return sessionByQuery.getExecutionSession(query);
  }