NotNull annotation is not operating as expected - 5.4.18.Final

I have upgraded my hibernate- core library from 5.4.11.Final to 5.4.18.Final release. During unit testing, I have noticed that in cases where NotNull annotation is used for ManyToOne JPA joins, the expected inner join in the generated query became left outer join. It seems that for 5.4.18.Final release NotNull annotation in for these cases is not operating as expected. Is there any explanation for this?

Note: I have by passed it by removing @NotNull before the @ManyToOne and by applying optional = false.

This was a bug that was fixed some version. If you want the JPA association to be non-optional you must specify optional = false like you seem to have figured out already.

1 Like

Thank you very much for your response! Could you please specify which was that bug exactly? I need to include this information to the relevant documentation of hibernate upgrade for my code.

I think it was [HHH-14129] Bidirectional relationship with @NotNull fails to save - Hibernate JIRA but I really can’t remember anymore. You would have to look into the issue tracker.

1 Like

I am really grateful! Thank you! :slight_smile: