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
ManyToOneassociation 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
ManyToOneentities 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 of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
