Hibernate ORM will currently allow such a mapping:
The association is marked as non-optional, but then @NotFound is used because some foreign keys don’t point to anything, which means the association is, in fact, optional. There is clearly a contradiction in this mapping, so Hibernate ORM should probably reject it on startup. Currently (ORM 5.6.12.Final, 6.1.5.Final, and 6.2.0-SNAPSHOT), Hibernate ORM will accept this mapping, but will then fail to load any entity that has such a “not found” association, simply returning null for such entities when calling session.get or session.multiLoad. Which is not very useful. See also https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/.60.40NotFound.60.20and.20.60optional.20.3D.20false.60 |