Interface QueryConverter<T>

  • Type Parameters:
    T - The raw query type

    public interface QueryConverter<T>
    Callers of DatastoreParameters that use slowQuery() or slowQueryWithInput() must implement this interface in order to properly record slow queries for their framework. Note: Implementations of this interface MUST guarantee thread-safety.
    Since:
    3.36.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String toObfuscatedQueryString​(T rawQuery)
      Takes a raw query object and return it as a String representing an obfuscated form of the query.
      java.lang.String toRawQueryString​(T rawQuery)
      Takes a raw query object and returns it as a String representing the query.
    • Method Detail

      • toRawQueryString

        java.lang.String toRawQueryString​(T rawQuery)
        Takes a raw query object and returns it as a String representing the query. This method should return a value that includes any parameter values (if possible).
        Parameters:
        rawQuery - the raw query object
        Returns:
        the raw query object in String form
      • toObfuscatedQueryString

        java.lang.String toObfuscatedQueryString​(T rawQuery)
        Takes a raw query object and return it as a String representing an obfuscated form of the query. It is VERY important that extra care be taken to properly obfuscate the raw query to prevent any potentially sensitive information from leaking.

        Sensitive information generally includes any changing values that the caller includes in the query. Replacement patterns are the responsibility of the caller but SHOULD coalesce queries that only differ by parameter values down a single unique String. For example, the following SQL queries will coalesce into a single query:

        • SELECT * FROM table1 WHERE parameter1 = 'value1';
        • SELECT * FROM table1 WHERE parameter1 = 'value2';

        Result: SELECT * FROM table1 WHERE parameter1 = ?

        NOTE: This method MUST return a different value than toRawQueryString(Object) otherwise slow sql processing will NOT occur.

        Parameters:
        rawQuery - the raw query object
        Returns:
        the obfuscated version of the raw query object in String form