Say I have the following entities
{noformat}User { @Id id: String name: String }
Order { @Id id: String @ManyToOne(fetch = FetchType.EAGER) @JoinColumn user: User // Meant to be different from Order.user // This extra field makes Hibernate use several queries when fetching which then leads to this bug @ManyToOne(fetch = FetchType.EAGER) @JoinColumn targetUser: User @OneToMany(targetEntity=OrderItem.class, mappedBy="order", fetch=FetchType.EAGER) orderItems: Set<OrderItem> }
OrderItem { @Id id: String @ManyToOne(fetch = FetchType.LAZY) @JoinColumn order: Order // Same as Order.user // Note that unlike Order.user, here it is LAZY @ManyToOne(fetch = FetchType.LAZY) @JoinColumn user: User }{noformat}
Fetching a single entity works well and returns an Order with all the relationships populated. But fetching multiple entities returns Order with Order.user not initialised.
This issue is present with and without bytecode enhancement.
- I’ll add a PR with a test case shortly. - - done |
|