-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Dual JOIN FETCH doubles number of child records on lazy list
PostPosted: Wed Jan 15, 2014 4:20 pm 
Newbie

Joined: Wed Jan 15, 2014 3:48 pm
Posts: 2
In a JPA 2.0 application, a dual JOIN FETCH statement returns incorrect results when one of the properties is a list with FetchType.LAZY; the list property has all records duplicated after execution of the query:
SELECT p FROM test_parent p JOIN FETCH p.children1 JOIN FETCH p.children2

Here we have one parent entity class and two child entity classes, associated via @OneToMany relationships from the parent class. The parent is tied to one child class via a Map, and to the other via a List. Both collection properties are FetchType.LAZY:

public class Parent {
@Id
@Column(name = "parentId", unique = true, nullable = false)
public int id;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "parent")
@MapKey(name = "myval")
public Map<Integer, Child1> children1 = new HashMap<>();

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "parent")
public List<Child2> children2 = new ArrayList<>();
}

I created a JIRA defect for this defect (HHH-7895), but was asked to post to the forum first. A full test case that includes the child classes is attached to the defect.

Comments appreciated.

Thanks,

Uli


Top
 Profile  
 
 Post subject: Re: Dual JOIN FETCH doubles number of child records on lazy list
PostPosted: Wed Jan 22, 2014 3:52 pm 
Newbie

Joined: Wed Jan 15, 2014 3:48 pm
Posts: 2
Anyone?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.