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);
int location id = workgroup.getLocation().getId(); Location location = manager.find(Location.class, id); workgroup.setLocation(location); manager.merge(workgroup);
is the workgroup object managed?