[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HHH-6783) Using FetchType.EAGER with @ElementCollection results in multiple entity copies returned via Criteria query
Wojciech Biela (JIRA)
noreply at atlassian.com
Wed Nov 2 19:30:19 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44222#comment-44222 ]
Wojciech Biela edited comment on HHH-6783 at 11/2/11 6:28 PM:
--------------------------------------------------------------
I also found the same problem, and have spent a few hours figuring it out. With lazy fetching works one way, with eager the other, the argument that it is by design and not a bug would stand if it would behave the same way in both cases.
Anyway why does a user of the API have to care about what kind of join is done there under. If I save 3 entities, I want to fetch 3, not 5.
A workaround for me was to use {{setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)}} on the criteria object.
was (Author: ilfrin):
I also found the same problem, and have spent a few hours figuring it out. With lazy fetching works one way, with eager the other, the argument that it is by design and not a bug would stand if it would behave the same way in both cases.
Anyway why does a user of the API have to care about what kind of join is done there under. If I save 3 entities, I want to fetch 3, not 5.
> Using FetchType.EAGER with @ElementCollection results in multiple entity copies returned via Criteria query
> -----------------------------------------------------------------------------------------------------------
>
> Key: HHH-6783
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6783
> Project: Hibernate Core
> Issue Type: Bug
> Components: annotations
> Affects Versions: 3.6.0
> Environment: MySQL
> Reporter: Greg Burcher
>
> If we specify FetchType.EAGER on an @ElementCollection:
> @ElementCollection(fetch = FetchType.EAGER)
> @Column(name = "emailAddress")
> private Set<String> emailAddresses;
> then request all persisted objects of this class via Criteria:
> session.createCriteria(ReportSchedule.class).list();
> The returned list contains multiple references to each ReportSchedule, one per email address.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list