/**
   * INTERNAL: Check to see if a custom query should be used for this query. This is done before the
   * query is copied and prepared/executed. null means there is none.
   */
  protected DatabaseQuery checkForCustomQuery(
      AbstractSession session, AbstractRecord translationRow) {
    checkDescriptor(session);

    // check if user defined a custom query
    DescriptorQueryManager queryManager = this.descriptor.getQueryManager();
    if ((!isCallQuery()) // this is not a hand-coded (custom SQL, SDK etc.) call
        && (!isUserDefined()) // and this is not a user-defined query (in the query manager)
        && queryManager
            .hasDeleteQuery()) { // and there is a user-defined query (in the query manager)
      return queryManager.getDeleteQuery();
    }

    return null;
  }