Decorator for class methods that do queries.