Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360728 - QueryHints.BATCH queries are not (always) executed if there is a FetchType.Lazy annotation value on the collection
Summary: QueryHints.BATCH queries are not (always) executed if there is a FetchType.La...
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-12 16:44 EDT by Martin Marinschek CLA
Modified: 2022-06-09 10:10 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Marinschek CLA 2011-10-12 16:44:17 EDT
Build Identifier: 2.2.1

See the following code:

ForeignReferenceMapping#batchedValueFromRow:

    protected Object batchedValueFromRow(AbstractRecord row, ObjectLevelReadQuery query, CacheKey parentCacheKey) {
        ReadQuery batchQuery = (ReadQuery)query.getProperty(this);
        if (batchQuery == null) {
            if (query.hasBatchReadAttributes()) {
                Map<DatabaseMapping, ReadQuery> queries = query.getBatchFetchPolicy().getMappingQueries();
                if (queries != null) {
                    batchQuery = queries.get(this);
                }
            }
            if (batchQuery == null) {
                batchQuery = prepareNestedBatchQuery(query);
                batchQuery.setIsExecutionClone(true);
            } else {
                batchQuery = (ReadQuery)batchQuery.clone();
                batchQuery.setIsExecutionClone(true);
            }
            query.setProperty(this, batchQuery);
        }
        return this.indirectionPolicy.valueFromBatchQuery(batchQuery, row, query, parentCacheKey);
    }

this references the indirection-policy for this mapping. Depending on the annotations, this indirection-policy might be set for lazy fetching. However, if I specify a Batch QueryHint, my assumption would be that the batch is always executed, and the annotations are disregarded.

Reproducible: Always
Comment 1 Tom Ware CLA 2011-10-13 13:33:30 EDT
Where are you expecting to see the batch query?  On the initial call, or when the LAZY relationship is triggered?

Batch queries should run when the relationship is triggered.  For EAGER relationships that will be right away, but for LAZY relationships, it will occur when the relationship is first traversed.
Comment 2 Tom Ware CLA 2011-10-31 13:23:38 EDT
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.
Comment 3 James Sutherland CLA 2013-07-09 15:23:35 EDT
No, batch fetching supports LAZY.  If you want the relationships instantiated, the specify a LoadGroup.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:55 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:10:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink