openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Russell (JIRA)" <j...@apache.org>
Subject [jira] Updated: (OPENJPA-112) Native queries and named parameters: poor error message
Date Sat, 14 Jul 2007 22:06:05 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Craig Russell updated OPENJPA-112:
----------------------------------

    Attachment: openjpa-112.patch

Please review this patch. It's a little tricky to describe the conditions under which this
user error will be encountered. By the time this error is found, the parameters have already
been set and the error message must cater to lots of different situations.

> Native queries and named parameters: poor error message
> -------------------------------------------------------
>
>                 Key: OPENJPA-112
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-112
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: windows xp, openjpa_097_incubating
>            Reporter: Patrick Linskey
>            Priority: Minor
>             Fix For: 0.9.8
>
>         Attachments: openjpa-112.patch
>
>
> native queries fail when use named parameters
>  int parm3 = 100;
> String sql = "SELECT deptno,budget,NAME,MGR_EMPID,REPORTSTO_DEPTNO FROM DeptBean WHERE
deptno >= :deptno ";
> Query getDept = _em.createNativeQuery(sql,DeptBean.class
> getDept.setParameter("deptno",parm3);
> List<DeptBean> rl = (getDept.getResultList());
> <4|false|0.9.7-incubating-SNAPSHOT> org.apache.openjpa.persistence.ArgumentException:
The parameter name or position "deptno" passed to execute() is not valid.  All map keys must
be a declared parameter name or a number matching the parameter position. 
> 	at org.apache.openjpa.kernel.QueryImpl.toParameterArray(QueryImpl.java:897)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:825)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:763)
> 	at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:520)
> 	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:224)
> 	at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:264)
> 	at com.ibm.ws.query.tests.JUNamedNativeQueryTest.testSelectDeptBean2(JUNamedNativeQueryTest.java:514)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:615)
> 	at junit.framework.TestCase.runTest(Unknown Source)
> 	at junit.framework.TestCase.runBare(Unknown Source)
> 	at junit.framework.TestResult$1.protect(Unknown Source)
> 	at junit.framework.TestResult.runProtected(Unknown Source)
> 	at junit.framework.TestResult.run(Unknown Source)
> 	at junit.framework.TestCase.run(Unknown Source)
> 	at junit.framework.TestSuite.runTest(Unknown Source)
> 	at junit.framework.TestSuite.run(Unknown Source)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message