Lazy enhanced entity as relationship is always loaded in a criteria query

Description

When lazy enhancement is enabled and given this entity

When this entity is queried:

The related user is always retrieved from DB:

This is due to the shortcut in
DefaultLoadEventListener#proxyOrLoad:

where hasProxy() is implemented in AbstractEntityPersister:

So this is always "false" for a lazy enhanced entity. I don't think that always issuing db queries while loading a relation is a desired effect

Test case: https://github.com/nikowitt/hibernate-test-case-templates/tree/HHH-12642-alwayloadfromdb

Environment

None

Assignee

Unassigned

Reporter

Niko Wittenbeck

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure