1 Reply Latest reply on Aug 19, 2007 12:21 PM by wayne baylor

    How to prepare for EntityManager.refresh()

    Octavio Newbie

      The following throws an IllegalArgumentException because the location entity is not 'Managed':

      Snippet 1:

       Location location = workgroup.getLocation();
       manager.refresh(location); //throws exception
       manager.merge(workgroup);
      


      My workarround is Snippet 2:
       int location id = workgroup.getLocation().getId();
       Location location = manager.find(Location.class, id);
       workgroup.setLocation(location);
       manager.merge(workgroup);
      


      What did I mis in Snippet 1 to be able to refresh?

      Appreciate your comments,

      Octavio