public static String createQueryLogMessage ( String query , List < Object > parameterValues ) { // builder for log message StringBuilder builder = new StringBuilder ( ) ; // log the JPQL query string builder . append ( "Query: \"" ) ; builder . append ( query ) ; builder . append ( "\"" ) ; // append parameter value list if ( parameterValues != null && parameterValues . size ( ) > 0 ) { builder . append ( ", parameters: { " ) ; // parameter value iterator Iterator < Object > parameterIterator = parameterValues . iterator ( ) ; // iterate over all parameter values while ( parameterIterator . hasNext ( ) ) { // use private helper to create string representation builder . append ( objectToString ( parameterIterator . next ( ) ) ) ; // append comma if more values follow if ( parameterIterator . hasNext ( ) ) { builder . append ( ", " ) ; } } // closing bracket builder . append ( " }" ) ; } // return result return builder . toString ( ) ; }
Method to create a human readable log message regarding a generated query .