It would be useful if the <any> element would support the not-found="ignore|exception" setting. Due to the nature of any-mappings it's impossible to use on-delete cascades at the database layer, so it's very likely that ObjectNotFoundExceptions occur.
Currently the only work-around to gracefully handle such situations seems to be the implementation of a custom EntityNotFoundDelegate that doesn't throw an exception.
BTW: Even a custom EntityNotFoundDelegate doesn't help as this leads to a NullPointerException somewhere in Hibernate. So this renders any-mappings pretty much useless in most situations.
A feasible (though not very elegant) solution is to use a custom Type that extends AnyType and calls session.internalLoad(entityName, id, false, true) instead of session.internalLoad(entityName, id, false, false).
I wonder if it would be a good idea to make this the default behavior of AnyType.java for the reasons stated in the issue's description above.
I agree, this option should be available.