Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328062

Summary: QueryHints.BATCH does not work with navigations
Product: z_Archived Reporter: Frank Schwarz <fs5>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P2 CC: cubukcuoglu.baris, jamesssss, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
stacktrace
none
reproducer none

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