2 Replies Latest reply on May 2, 2006 12:41 PM by Gavin King

    updating the view with em.refresh()

    Fane Babanu Newbie

      I have a domain model like this: Company -* Department -* Employee

      On a Company's page I list all Departments with their Employees. The code on the page (facelets) just iterates and displays the Departments and their Employees.

      When I add or delete an Employee, the page has to be updated so I do this in the backing bean:

      departments = company.getDepartments();

      This works ok when adding an Employee. But when I refresh the company after *deleting* an employee I get this:

      javax.ejb.EJBTransactionRolledbackException: javax.persistence.EntityNotFoundException: org.hibernat
      e.UnresolvableObjectException: No row with the given identifier exists: [com.example.Employee#231]

      Any idea why, or how to avoid this? Or maybe a different way of refreshing my view? Thanks.


      I also tried like this instead of refreshing the company:

      departments = departmentDAO.getAll(); // straightforward em query call

      No error now, but the the view isn't updated correctly after either adding or deleting an Employee (new Employees don't show up immediately, deleted ones still show).

      Any help would be highly appreciated. Thanks.