This is from the JPA spec - Sounds like cascade=REMOVE should not be used on ManyToMany. However I'm recalling that some databases do provide DDL for the kind of cascade delete behavior that I want.

2.1.7 - "The relationship modeling annotation constrains the use of the cascade=REMOVE specification. The cascade=REMOVE specification should only be applied to associations that are specified as One- ToOne or OneToMany. Applications that apply cascade=REMOVE to other associations are not portable."

On 4/3/2009 10:43 AM, Paul Copeland wrote:
Will CascadeType.REMOVE on a ManyToMany mapping remove the join table row? Even if the Collections has not been loaded lazily? Or do I have to iterate over the Collection and remove each element before removing the enity? I do NOT want to remove the referenced Entity on the other side of the ManyToMany association, just the row in the join table.

@ManyToMany (fetch=FetchType.LAZY, cascade={CascadeType.PERSIST,CascadeType.REMOVE})

- Paul





Reply via email to