Uploaded image for project: 'Hibernate ORM'
  1. HHH-12687

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

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • Last commented by a user?:
      true
    • Sprint:

      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:

      	@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.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                gbadner Gail Badner
                Reporter:
                gbadner Gail Badner
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: