Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328062 - QueryHints.BATCH does not work with navigations
Summary: QueryHints.BATCH does not work with navigations
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-18 14:50 EDT by Frank Schwarz CLA
Modified: 2022-06-09 10:20 EDT (History)
3 users (show)

See Also:


Attachments
stacktrace (5.45 KB, text/plain)
2010-10-18 14:51 EDT, Frank Schwarz CLA
no flags Details
reproducer (6.34 KB, application/x-download)
2010-10-18 14:54 EDT, Frank Schwarz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Schwarz CLA 2010-10-18 14:50:15 EDT
Build Identifier: Trunk

Object model is:

Abteilung (department) ->* Mitarbeiter (employee) -> * Projekt (projekt) ->* Standort (location)

TypedQuery<Abteilung> query = em.createQuery("SELECT a FROM Abteilung a", Abteilung.class);
query.setHint(QueryHints.BATCH, "a.mitarbeiter.projekte");


will result in
Exception Description: The expression has not been initialized correctly.  Only a single ExpressionBuilder should be used for a query. 
For parallel expressions, the query class must be provided to the ExpressionBuilder constructor, and the query's ExpressionBuilder must 
always be on the left side of the expression. 
Expression: [
Base jpatage.fetchplans.model.Abteilung]
Query: ReadAllQuery(referenceClass=Abteilung sql="SELECT ID, NAME FROM ABTEILUNG")


This query will work though with above query hint:

"SELECT distinct a FROM Abteilung a join a.mitarbeiter m join m.projekte p where p.name is not null


Reproducible: Always
Comment 1 Frank Schwarz CLA 2010-10-18 14:51:17 EDT
Created attachment 181119 [details]
stacktrace
Comment 2 Frank Schwarz CLA 2010-10-18 14:54:23 EDT
Created attachment 181120 [details]
reproducer

Please have a look at methods "queryBatchFetch" or "queryBatchFetchExists" or "queryBatchFetchIn". All of them will fail with the stated exception.
Comment 3 Tom Ware CLA 2010-11-01 11:29:29 EDT
Setting target and priority.  See the following page for details about these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 4 Baris Cubukcuoglu CLA 2014-03-05 11:18:30 EST
This bug still exists in the version 2.5.1. 

It works only, if I transform the nested query to an @NamedQuery, like:

@NamedQuery(name = "CustomerOrder.Test", query = "SELECT o FROM CustomerOrder o", hints = {@QueryHint(name = QueryHints.BATCH, value = "o.orderProducts.product"),
@QueryHint(name = QueryHints.BATCH_TYPE, value = "IN") }) })
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:20:31 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink