| Summary: | Query hint eclipselink.join-fetch can cause wrongly populated data | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Anssi Törmä <anssi.torma> | ||||||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P2 | CC: | andrei.ilitchev, eclipselink.orm-inbox, mocanushtefan, tom.ware | ||||||||||
| Version: | unspecified | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows 7 | ||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Anssi Törmä
Created attachment 208287 [details]
test cases
I encounter the same problem. It seems it might be related to applying join-fetch hints that share the beginning of the path. I have a hierarchy like this: A <-* B (in A I have List<B> children) B <-* C (in B I have List<C> childrenC) B <-* D (in B I have List<D> childrenD) I have the query select a from A a Each of the following hints work separately: qFetch.setHint(QueryHints.LEFT_FETCH, "a.children.childrenC") qFetch.setHint(QueryHints.FETCH, "a.children.childrenD"); However, they do not work together. I have attached a test case. Created attachment 208310 [details]
Test case for multiple join fetch
I'm sorry for a small typo, both hints are QueryHints.FETCH: qFetch.setHint(QueryHints.FETCH, "a.children.childrenC"); qFetch.setHint(QueryHints.FETCH, "a.children.childrenD"); I have investigated by myself this problem, and found it to reside in JoinedAttributeManager, method prepareJoinExpressions. There is a declaration in that method: List groupedExpressionList = new ArrayList(getJoinedAttributeExpressions().size()); For the test case I described, there will be 4 expressions added through this line of code: this.setJoinedAttributeExpressions_(groupedExpressionList); The 4 expressions correspond to: 1. a.children 2. a.children.childrenC 3. a.children 4. a.children.childrenD By hacking the "groupedExpressionList" and turning it into a Set, everything seems to work fine. HTH Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. Created attachment 214897 [details]
Suggested patch
- defined new versions of anyOf and anyOfAllowingNone methods taking boolean parameter that indicates whether to create a new expression or return existing one (the pattern of get and getAllowingNull methods);
- copied into FETCH processing ObjectAggregateMapping's handling from LEFT_FETCH.
Test: EntityManagerJUnitTestSuite.testNestedFetchQueryHints
Created attachment 214940 [details]
Suggested patch + batch test
Added to the previous patch a new test EntityManagerJUnitTestSuite.testNestedBatchQueryHints to verify nested batching.
Checked the patch into both trunk (2.4) and 2.3.3. Reviewed by James. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |