Issue: Records are deleting automatically from sub entity without firing any save/update statement. Need to prevent that deletion.
Below is entity:
@Entity
@Table(name="siteuser")
public class User implements UserDetails {
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "siteuser_subcategory",
joinColumns = {@JoinColumn(name = "userId") },
inverseJoinColumns = { @JoinColumn(name = "subCategoryId") })
@JsonIgnore
private List<SubCategory> subcategoryList = new ArrayList<SubCategory>();
}
Here in cascade
I tried all possible options DETACH,MERGE,PERSIST,REFRESH,REMOVE
but no solution.
Also there is no any physical class entity for table 'siteuser_subcategory'. That table managed by only this above code.
I tried many ways to solve this issue as explained in this link Why does Hibernate try to delete when I try to update/insert?
Please guide for better solutions or anyway by try it.
Thank you in advance.