Case:
Entity declaration:
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<Foo> foos = Lists.newArrayList();
This block
user.getFoos().clear();
// instantiate `foos`, eg: final List<Foo> foos = myService.createFoos(bla, bla);
user.setFoos(foos);
generates this error:
org.springframework.orm.jpa.JpaSystemException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.github.lalou.jonathan.blabla.User.foos