/** * Adds a prepared statement to this storage for later retrieval. * * @param object * The object which will be the key of the mapping. */ public void addPreparedStatement(Object object) { String sql = sqlThreadLocalStack.getLast(); preparedStatements.put(object, new QueryInformation(sql)); if (LOG.isDebugEnabled()) { LOG.debug("Recorded prepared sql statement: " + sql); } }
/** * Clears all the parameters in the array. * * @param preparedStatement * The prepared statement for which all parameters are going to be cleared. */ protected void clearParameters(Object preparedStatement) { QueryInformation queryAndParameters = preparedStatements.getIfPresent(preparedStatement); if (null == queryAndParameters) { if (LOG.isDebugEnabled()) { LOG.debug("Could not get the prepared statement from the cache to clear the parameters! Prepared Statement:" + preparedStatement); } return; } queryAndParameters.clearParameters(); }
String[] parameters = queryAndParameters.getParameters();
/** * Returns a stored parameters for the object. * * @param object * The object which will be used to look up in the map. * @return The list of parameters or <code> null </code> if there is no container for the given * SQL statement or there are no parameters captured within this SQL statement. */ protected List<String> getParameters(Object object) { QueryInformation queryAndParameters = preparedStatements.getIfPresent(object); if (null == queryAndParameters) { return null; } else { return queryAndParameters.getParametersAsList(); } }