sql->hql refactoring