We're updating the issue view to help you get more done. 

ManyToOne associations in embeddable collection elements and composite IDs are always eagerly loaded

Description

A regression was introduced when load plans were introduced in 4.3 that results in many-to-one associations to be eagerly loaded if they are embedded in an embeddable collection element.

For example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 @Entity(name = "Parent") public static class Parent { @Id @GeneratedValue private int id; private ContainedChild containedChild; @ElementCollection private Set<ContainedChild> containedChildren = new HashSet<ContainedChild>(); } @Entity(name = "Child") public static class Child { @Id @GeneratedValue private int id; } @Embeddable public static class ContainedChild { @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) private Child child; ContainedChild() { } ContainedChild(Child child) { this.child = child; } }

When a Parent entity is loaded, containedChild.child will be lazy (as expected).

When a Parent#containedChildren is initialized, the child contained in each ContainedChild collection element will be non-lazy. These child entities should be lazy.

I believe that many-to-one associations in composite IDs will also be eagerly loaded, even when mapped as lazy. I need to look into this further though.

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.2.21

Components

Affects versions

5.2.17
5.3.1
5.0.12
5.1.14

Priority

Major