Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NOT Using Named Parameters in a Native Query

alexs12345678Jan 18 2007 — edited Mar 29 2007
Hi!

like it is written in the Toplink JPA Extensions reference Toplink supports using named parameters in native queries.

See example from http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html:
Example 1-11 Specifying a Named Parameter With #
Query queryEmployees = entityManager.createNativeQuery(
"SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = #firstname"
);
queryEmployeeByFirstName.setParameter("firstName", "Joan");
Collection employees = queryEmployees.getResultList();


But I want to use "#" in the SQL statement so I want to disable this parameter binding somehow and let the query just execute the SELECT statement I deliver.

I have tried to add the property
<property name="toplink.jdbc.bind-parameters" value="false"/>
into the persistence.xml and I have also tried to add the query hint
query.setHint(TopLinkQueryHints.BIND_PARAMETERS, HintValues.FALSE);
but none of them prevents the # to be uses as a paramter. this causes the exception:

Exception [TOPLINK-6132] (Oracle TopLink Essentials - 9.1 (Build b22)): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Query argument ######' not found in list of parameters provided during query execution.
Query: ReadAllQuery(de.merck.compas.material.SimilarLocalMaterialListItemBV)


The SQL Statement is
SELECT * FROM TABLE (
CAST ( RCGC.PHA_P_COMPASMDM.LookupSimilarMats
( 'COC003','10021500150000000997','30','30','040','standard','','001001','001001','123456','##########','X','X','X','X','U' )
AS RCGC.PHA_COMPAS_SIMILAR_MATS ) )



I am using the latest Toplink essentials build together with an Oracle 9.2i DB in a Java SE web application.


Can anyone give me a little hint what to do?


Thanks and best regards,
Alex
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2007
Added on Jan 18 2007
8 comments
3,754 views