Skip to content

Instantly share code, notes, and snippets.

@GongLe
Created July 30, 2013 10:10
Show Gist options
  • Select an option

  • Save GongLe/6111770 to your computer and use it in GitHub Desktop.

Select an option

Save GongLe/6111770 to your computer and use it in GitHub Desktop.
JPA @onetomany 级联删除Many端
When we use JPA @oneToMany
if you remove a dependent object from a OneToMany collection it will not be deleted, JPA1.0 don’t support it itself, it requires that you explicitly call remove() on it.
In JPA2.0 ,you need do add “orphanRemoval” to “@OneToMany” ,
just like this:
@OneToMany(mappedBy = "A", orphanRemoval=true,cascade = CascadeType.ALL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment