My Oracle Support Banner

Setting QueryHints.CURSOR On A NamedQuery Throws QueryException "Query Has To Be Reinitialised ..." (Doc ID 2513228.1)

Last updated on MARCH 16, 2021

Applies to:

Oracle TopLink - Version 12.1.2.0.0 and later
Information in this document applies to any platform.

Symptoms

ENVIRONMENT
--------------------
TopLink 12.1.2.0
EclipseLink 2.4.2 (or 2.6.2)
WebLogic 10.3.6
RDBMS 12.1.0.2.0


PROBLEM
-------------
Executing a named-native query that uses the hint eclipselink.cursor fails with an exception message of "Query has to be reinitialized with a cursor stream policy.".


ERROR MESSAGE
----------------------
there is no real stack trace, but an EclipseLink error message:
Query: DataModifyQuery(sql="CREATE TABLE TESTENTITY (ID BIGINT NOT NULL, PRIMARY KEY (ID))")
[EL Warning]: 2017-03-02 23:52:06.693--UnitOfWork(283828842)--Exception [EclipseLink-6105] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query has to be reinitialized with a cursor stream policy.
Query: DataReadQuery(name="allTestEntitiesAnnotated" sql="SELECT ID FROM TESTENTITY")


OBSERVATIONS
---------------------
It is suspected that this happens because SQLCall.returnType in EJBQueryImpl.databaseQuery.queryMechanism.call is still set to RETURN_MANY_ROWS even though it should have been RETURN_CURSOR after setting the above hint..


WORKAROUNDS
---------------------
1. can be set for the query in orm.xml (or be annotated equivalently). But this assumes the query will only ever be used in combination with a cursored result.

2. Forcing Eclipselink to prepare the query again also fixes the problem but couples the calling code to implementation details of Eclipselink: ((EJBQueryImpl)jpaQuery).getDatabaseQuery().setIsPrepared(false);

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.