Well if you don't use @NotFound then according to the documentation hibernate throws an exception (I assume the exception is thrown when initializing the proxy), which is exactly what I would like to happen for the non-owning side of a one-to-one relation. Of course I have no problem with adding support for @NotFound on a non-owning relation. But still if you are NOT using @NotFound on the owning side of a lazy to-one relation and your DB is missing an appropriate FK, then your Domain Model is inconsistent with the database. In this case hibernate will use a proxy and a != null check will not initialize that proxy and initializing the proxy will cause an exception. I think this is exactly how it should be and I just want the same behaviour for a non-owning lazy to-one relation. I don't see how the use case is different for the owning side of a lazy to-one relation. In both cases you can encounter extremely similar problems if the DB does not have the appropriate constraints, yet in case of the owning side you use a proxy and in case of the non-owning side you don't. In both cases you could just use a proxy and in both cases initializing the proxy could throw an exception if the FK or not null constraint is missing. An in both cases you could (in theory) use @NotFound. Btw I have never used @NotFound, but I think the only way to implement it properly is for @NotFound(IGNORE) to imply eager loading, because otherwise you can't decide whether to use null or a proxy. Also is it even allowed to use @NotFound(IGNORE) on a non-optional to-one relation? I thought option=false means that the value can't be null, yet @NotFound(IGNORE) means place null there if you can't find a value. |