Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324406 - Wrong Index in ReportItem when @Embeddable Objects are used in ReportQuery
Summary: Wrong Index in ReportItem when @Embeddable Objects are used in ReportQuery
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-03 08:35 EDT by thomas.spiegl CLA
Modified: 2022-06-09 10:30 EDT (History)
3 users (show)

See Also:


Attachments
Patch (1.82 KB, patch)
2010-09-03 08:38 EDT, thomas.spiegl CLA
peter.krogh: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description thomas.spiegl CLA 2010-09-03 08:35:49 EDT
Build Identifier: 2.2.0

If an AggregateObjectMapping is part of the ReportQueryResult then ReportItem.resultIndex may be wrong. See Steps to Reproduce ...


Fix:
ExpressionQueryMechanism.java
replace: line 593
++itemOffset; //only a single attribute can be selected
by:

if (item.getMapping() instanceof AggregateObjectMapping) {
                        itemOffset += item.getMapping().getFields().size(); // Aggregate object may consist out of 1..n fields
                    } else {
                        ++itemOffset; //only a single attribute can be selected
                    }

Reproducible: Always

Steps to Reproduce:
Example:  

1. create @Embeddable class Money { String currency; BigDecimal value; }
2. create @Entity Item {Long id; Money money; String itemNumber; }
3. execute Query: select new QueryObject(i.id, i.money, i.itemNumber) from Items i

Error:
ReportItem.resultIndex = 2 for ResultItem i.itemNumber, should be 4 as Money has 2 fields
Comment 1 thomas.spiegl CLA 2010-09-03 08:38:50 EDT
Created attachment 178138 [details]
Patch
Comment 2 Tom Ware CLA 2010-09-13 15:00:01 EDT
Investigating submitted patch.
Comment 3 Tom Ware CLA 2010-09-14 10:20:03 EDT
Added fix with minor update.

Added test to EntityManagerJunitTestSuite

Tested with JPA LRG

Reviewed by Tom Ware - reviewed user-submitted fix
Comment 4 Peter Krogh CLA 2010-12-08 14:33:34 EST
moving ipLog flag to patch
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:30:41 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink