We have an application which contains some dirty data where foreign keys are defined with the value 0 instead of null when there should be no connection. Most of it has been corrected now, but we are not sure everything is corrected, and the data might be updated by external applications later on.
We are currently using NotFoundAction.IGNORE to give an empty reference in the entity if no connection is found. The problem with this approach is that we are never notified when Hibernate meets dirty data. Using NotFoundAction.EXCEPTION reports dirty data, but it also crashes the current request.
What I was thinking, was that it would be nice to have a third option for the NotFound annotation that sets the value in the entity to a null, but logs the error.
|