Refactoring queries to repositories with specifications