Persistent Collection is empty

Description

When enhancement-as-proxy is enabled (hibernate.bytecode.allow_enhancement_as_proxy set to true) with bytecode enhancement for lazy initialization, a lazy @OneToMany (or @ElementCollection) is initialized but remains empty when it has elements.

It only happens when the entity is already present in the persistence context, thus returned as-is by DefaultLoadEventListener.doLoad:518.

It's present in the persistent context because another Entity referencing it through a lazy @OneToOne with @LazyToOne(LazyToOneOption.NO_PROXY) has been loaded.

EDIT: I’m currently not able to reproduce this issue outside of the real Spring app.

Environment

None

Assignee

Unassigned

Reporter

Patrice Blanchardie

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Minor
Configure