DatabaseQuery applyToDatabaseQuery(Object valueToApply, DatabaseQuery query, ClassLoader loader, AbstractSession activeSession) {
if (query.isReadQuery()) {
ReadQuery readQuery = (ReadQuery)query;
if (readQuery.getQueryResultsCachePolicy() == null) {
readQuery.cacheQueryResults();
}
try {
readQuery.getQueryResultsCachePolicy().setMaximumCachedResults(Integer.parseInt((String)valueToApply));
} catch (NumberFormatException exception) {
throw QueryException.queryHintContainedInvalidIntegerValue(QueryHints.QUERY_RESULTS_CACHE_SIZE, valueToApply, exception);