Issue Details (XML | Word | Printable)

Key: OPENJPA-112
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Pinaki Poddar
Reporter: Patrick Linskey
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Native queries and named parameters: poor error message

Created: 25/Jan/07 01:38 AM   Updated: 31/Jul/08 08:50 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works openjpa-112.patch 2007-07-14 10:04 PM Craig Russell 1 kB
Environment: windows xp, openjpa_097_incubating
Issue Links:
Cloners
 

Resolution Date: 19/Jun/08 12:40 AM


 Description  « Hide
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)



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Patrick Linskey made changes - 25/Jan/07 01:38 AM
Field Original Value New Value
Link This issue is a clone of OPENJPA-111 [ OPENJPA-111 ]
Patrick Linskey added a comment - 25/Jan/07 01:38 AM
While the failure is legit (see OPENJPA-111), the error message should be more clear.

Patrick Linskey made changes - 01/Mar/07 01:12 AM
Fix Version/s 0.9.7 [ 12312340 ]
Patrick Linskey made changes - 01/Mar/07 02:04 AM
Priority Major [ 3 ] Minor [ 4 ]
Michael Dick made changes - 02/Apr/07 07:54 PM
Fix Version/s 0.9.7 [ 12312340 ]
Fix Version/s 0.9.8 [ 12312446 ]
Craig Russell added a comment - 14/Jul/07 10:04 PM
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.

Craig Russell made changes - 14/Jul/07 10:04 PM
Attachment openjpa-112.patch [ 12361840 ]
Craig Russell made changes - 14/Jul/07 10:05 PM
Assignee Craig Russell [ clr ]
Patrick Linskey made changes - 07/Aug/07 06:40 PM
Fix Version/s 0.9.8 [ 12312446 ]
Repository Revision Date User Message
ASF #669341 Thu Jun 19 00:40:17 UTC 2008 ppoddar OPENJPA-112,OPENJPA-111: Early check for 1-based positional parameter and no named parameter in native query. Also more specific error message
Files Changed
MODIFY /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
ADD /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/query/TestNativeQueryParameterBinding.java
MODIFY /openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties

Pinaki Poddar made changes - 19/Jun/08 12:40 AM
Assignee Craig Russell [ clr ] Pinaki Poddar [ ppoddar@apache.org ]
Pinaki Poddar added a comment - 19/Jun/08 12:40 AM
Committed revision 669341.

Pinaki Poddar made changes - 19/Jun/08 12:40 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Michael Dick made changes - 31/Jul/08 08:50 PM
Fix Version/s 1.2.0 [ 12313102 ]