Add checks for query passed to setCachedStatement