How does JPA orphanRemoval=true differ from the ON DELETE CASCADE DML clause

I am a little confused about the JPA 2.0 orphanRemoval attribute. I think I can see it is needed when I use my JPA provider’s DB generation tools to create the underlying database DDL to have an ON DELETE CASCADE on the particular relation. However, if the DB exists and it already has an ON … Read more

How to add “on delete cascade” constraints?

In PostgreSQL 8 is it possible to add ON DELETE CASCADES to the both foreign keys in the following table without dropping the latter? # \d scores Table “public.scores” Column | Type | Modifiers ———+———————–+———– id | character varying(32) | gid | integer | money | integer | not null quit | boolean | last_ip … Read more

What is the meaning of the CascadeType.ALL for a @ManyToOne JPA association

I think I misunderstood the meaning of cascading in the context of a @ManyToOne relationship. The case: public class User { @OneToMany(fetch = FetchType.EAGER) protected Set<Address> userAddresses; } public class Address { @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) protected User addressOwner; } What is the meaning of the cascade = CascadeType.ALL? For example, if I … Read more