I have a class called News
. Any news can have many Photo
. These are my table
news news_photo photo
-------------- ---------------------- ------------
| id | title | | id_news | id_photo | | id | url |
-------------- ---------------------- ------------
| | | |
|----------------------| |--------------|
This is my class News
@Entity
@Table(name = "news")
public class News extends ElementoPersistente implements Serializable{
...
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@JoinTable(name = "news_photo",
joinColumns = { @JoinColumn(name = "id_news")},
inverseJoinColumns = { @JoinColumn(name = "id_photo") })
private List<photo> photos;
...
}
When I remove an object from List<photo> photos
and then I save the object News
, the relative record is deleted from the table news_photo
but nothing is deleted inside the table photo
.
How can I delete both records inside news_photo
and photo
?
Thank you