| Summary: | JPQL simple child query generates unnecessary table join | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Bernard Missing name <bht237> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | jamesssss, tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows Vista | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Bernard Missing name
Created attachment 161230 [details]
NetBeans project in zip file
Setting target and priority. For information about the meaning of these settings see: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Note that the JPQL, "Select c from Child c where c.parent.id = :id" Is explictly doing a join from child to parent, so not very surprizing that the same join occurs in SQL. To correctly do this in JPQL you can use, "Select c from Child c where c.parent = :parent" and pass a parent object with its id set as parameter. EclipseLink also allows you to define QueryKeys that can be define for the foreign key column to allow querying like, "Select c from Child c where c.parentId = :id" ... But we could optimize this JPQL as it is a common mistake. Created attachment 176175 [details]
patch to optimize 1-1 joins
This has been fixed in trunk (2.2). Please verify your use case now works on the latest EclipseLink build. (as of tomorrow) SVN trunk commit: Bug#304923 optimize 1-1 joins https://bugs.eclipse.org/bugs/show_bug.cgi?id=304923 Code review: Andrei Changes: - Optimizes expression normalization to optimize unnecessary 1-1 joins (emp.addresss.id = :id => emp.ADDR_ID = :id). - Switches getOperations to public in PerformanceMonitor. - Fixes cache size monitor to exclude unit of work cache. - Test for 1-1 join optimization. Thanks very much for fixing this! There are still two open issues of the same type, 298494 and 300625. It might be easier to address these sooner than later (knowledge, setup costs). The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |