move query builder into entity