After discussions with Stephen Fikes and Guillaume, I've added resolutions
to the document.
In a nutshell, here is what we decided.
1) Ccombination of @NotFound(IGNORE) and non-optional
one-to-one/many-to-one will throw MappingException.
2) Combination of @NotFound(IGNORE) and "mappedBy" one-to-one/many-to-one
will log a WARN message that @NotFound(IGNORE) will be ignored and should
3) When a non-lazy association's join column is non-null and there is no
associated entity with the referenced column:
- log an INFO message with the exception in an INFO message with
ObjectNotFoundException including the entity name and referenced column and
value that was not found; (we decided to continue logging as INFO because
this condition can only happen if there is no foreign key; so in a sense,
the application "knows" this condition is possible)
- in the log message, if possible, include the association owner entity
and its ID; this will make it easier to clean up the inconsistency in the
- return a non-null entity with a null association.
On Mon, Sep 24, 2018 at 4:03 PM Gail Badner <gbadner(a)redhat.com> wrote:
As a result of fixing HHH-12436
;, some eager *-to-one
associations that were loaded using FetchMode.JOIN may instead be loaded
using FetchMode.SELECT, and vice-versa. In some cases, @NotFound behavior
is different depending on the FetchMode for the association.
The reason why FetchMode may change due to HHH-12436
is that the
ForeignKeyDirection of some *-to-one associations were incorrect.
Correcting the ForeignKeyDirection will result in a different
AssociationKey, which may ultimately affect the FetchMode Hibernate assigns
to an association.
My hope is to resolve the inconsistencies before fixing HHH-12436
;, so it does not result
in a change in application behavior.
I've created a Google Doc to document the inconsistencies and to make it
easier to discuss how to go about resolving them:
Please feel free to request access to the document if you wish to review
or add comments.