public class Data {
....
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY/*-, mappedBy = "userId"*/)
@JoinColumn(name = "userId")
public Set<MyData> getList() {
return list;
}
....
}
There was an upgrade change where mappedBy = “userId” was replaced by @JoinColumn(name = “userId”).
When I delete Data records it is supposed to delete MyData also as its CascadeType.REMOVE. After the upgrade I now I get an exception:
org.hibernate.exception.ConstraintViolationException: could not execute statement [(conn=200) Column 'userid' cannot be null] [update my_data set userId=null where userId=?]
So rather than deleing the records it is trying to set the userid as null (which is not allowed in the db) rather than deleting the records.
Maybe I have got something wrong on the mapping change on the upgrade?
I had also commented out the @NotFound(action = NotFoundAction.IGNORE). I would have only done this if hibernate was complaining and would not start.
I have now reinstated all the commented out not founds. Although the @OneToMany still complains, and improved my logging to catch these in the future. Passes all my tests for now.
If I have more errors I will try and do the reproducer.