Re: [hibernate-dev] *-to-one associations and @NotFound

2018-10-05 Thread Gail Badner
I thought of another case that hasn't been discussed fully. It's covered in
the section, Possible Anomalies - @NotFound(EXCEPTION) has no effect in
some cases - Non-Optional Associations.

Guillaume and Stephen, please take a look and let me know your thoughts.

Thanks,
Gail

On Fri, Oct 5, 2018 at 11:16 AM Gail Badner  wrote:

> 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
> be removed.
>
> 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 database;
>- return a non-null entity with a null association.
>
> Regards,
> Gail
>
> On Mon, Sep 24, 2018 at 4:03 PM Gail Badner  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:
>>
>>
>> https://docs.google.com/document/d/1o3Q6tYD5jjxC6Ok7vBYzxRGsixpG46p-5zDiDCAKLsI/
>>
>>
>> Please feel free to request access to the document if you wish to review
>> or add comments.
>>
>>
>> Regards,
>>
>> Gail
>>
>>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] *-to-one associations and @NotFound

2018-10-05 Thread Gail Badner
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
be removed.

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
   database;
   - return a non-null entity with a null association.

Regards,
Gail

On Mon, Sep 24, 2018 at 4:03 PM Gail Badner  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:
>
>
> https://docs.google.com/document/d/1o3Q6tYD5jjxC6Ok7vBYzxRGsixpG46p-5zDiDCAKLsI/
>
>
> Please feel free to request access to the document if you wish to review
> or add comments.
>
>
> Regards,
>
> Gail
>
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev