OneToOne relation with optional=false is not lazy loaded

Description

The attached test case contains two entity classes, connected by a @OneToOne relation:

The internet is full of smart advice that you could tell Hibernate to lazy-load the OneToOne relation even on the non-owner side, if (and only if) the relation is optional=false.

The given explanation is usually: a lazy-loading proxy can be inserted on that side, as we know that the relation can't be null (due to the optional=false).

I was always under the impression that it actually works, but I can't get it to work in my application now and also not in the attached example. I've tried different Hibernate versions, but I always get the same result (run mvn clean test -Dhibernate.version=... to try out a few on your own, if that helps): the relation Parent.child is always fetched eagerly with a second query.

Not sure if this is actually a bug, or a feature request. :wink:

Environment

None

Assignee

Unassigned

Reporter

Andreas Gudian

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure