The meaning of
CascadeType.ALL is that the persistence will propagate (cascade) all
EntityManager operations (
PERSIST, REMOVE, REFRESH, MERGE, DETACH) to the relating entities.
It seems in your case to be a bad idea, as removing an
Address would lead to removing the related
User. As a user can have multiple addresses, the other addresses would become orphans. However the inverse case (annotating the
User) would make sense – if an address belongs to a single user only, it is safe to propagate the removal of all addresses belonging to a user if this user is deleted.
BTW: you may want to add a
mappedBy="addressOwner" attribute to your
User to signal to the persistence provider that the join column should be in the ADDRESS table.