Handled the scenario when no entity manager is passed with closure query builder.