Sunday, March 27, 2011

org.hibernate.util.JDBCExceptionReporter ORA-01407: cannot update (...) to NULL

I faced this issue for a while this afternoon while deleting a row which has a column referenced by a child table.



The cause for this is due to an incorrect JPA mapping:

Solution:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "FK_QUESTION_ID", updatable=false, insertable=false)

updatable=false - column is not included in SQL INSERT statements generated by the persistence provider.
updatable=false - column is not included in SQL UPDATE statements generated by the persistence provider.

No comments: