Small refactor of query logic into private method getSingleResult