cleaner separation between select and count logic in AbstractRepository