ManyToOne associations in embeddable collection elements are always eagerly loaded in Hibernate 5
Issue
-
An entity includes an element collection of embeddable types with a
ManyToOne
association to another entity@Entity(name = "Parent") public static class Parent { @Id @GeneratedValue private int id; @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 the element collection is initialized, the associated
ManyToOne
entities will be eagerly loaded.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.