Issue Details (XML | Word | Printable)

Key: OPENJPA-196
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Marc Prud'hommeaux
Reporter: Marc Prud'hommeaux
Votes: 0
Watchers: 0
Operations

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

Ease the restrictions on forcing a matche between the number of declared and assigned positional parameters

Created: 01/Apr/07 04:28 PM   Updated: 02/Apr/07 10:00 PM
Return to search
Component/s: query
Affects Version/s: 0.9.0, 0.9.6
Fix Version/s: 0.9.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works OPENJPA-196.patch 2007-04-01 04:29 PM Marc Prud'hommeaux 0.8 kB

Resolution Date: 02/Apr/07 10:00 PM


 Description  « Hide
OpenJPA currently enforces that each positional parameter that is assigned in a query must actually be declared in that query, although the spec doesn't actually seem to mention that restriction.

As respoted by Dain Sundstorm on the OpenJPA mailing list:

Actually, I think there is a bigger problem... Say I have a query like this:

    SELECT x FROM foo AS x WHERE foo.name = ?2

The org.apache.openjpa.kernel.QueryImpl.assertParameters(...) code assumes that if I have 1 parameter it is numbered ?1, but in EJB 2.1 this was not a requirement and there are certification tests that verify you are allowed to have "unused" parameters (e.g, in my example about ?1 and ?N where N>2 are all not used). I couldn't find any text in the specification that says that all all positional parameters must be used in the query, but I did find text that say the EJB-QL 3.0 language is an extension of the EJB-QL 2.1 language:

"The Java Persistence query language is an extension of the Enterprise Java Beans query language, EJB QL, definedin[5]."

So I think we must remove the "extra-params" check, but I would be happy with a "don't check for extra-params flag".

-dain

On Mar 31, 2007, at 8:56 AM, Dain Sundstrom wrote:

I'm working on a CMP 2 implementation that delegates to OpenJPA for persistence. I'm running into a problem where I get the following exception:

org.apache.openjpa.persistence.ArgumentException : More parameters were passed to execute() than were declared: 4 parameters were specified for query execution, but only 2 parameters were declared in the query.


In CMP you declare finder and select methods that have parameters which are passed into the query engine. You can have as many parameters as you like but are not required to use them all, but it appears that OpenJPA is enforcing a restriction where if the EJB-QL text only lists say 2 parameters and I set 4 I get the above exception. In order of perference:

Is this spec required? If not, can we remove the check?

Is there a way to disable the check? If so, how?

Is there a way to determine the number of paramters a query takes? If so, I can change my code.

Is there a way to get the ejbql text from a Query object? If so, I'll write a quick parser to determine number of queries myself.

BTW, I'm currently using 0.9.6.

Thanks,

-dain



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Marc Prud'hommeaux made changes - 01/Apr/07 04:28 PM
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
Marc Prud'hommeaux added a comment - 01/Apr/07 04:29 PM
This siple patch removed the restirction.

Marc Prud'hommeaux made changes - 01/Apr/07 04:29 PM
Attachment OPENJPA-196.patch [ 12354700 ]
Repository Revision Date User Message
ASF #524939 Mon Apr 02 21:59:21 UTC 2007 mprudhom OPENJPA-196 Removed the requirement that the number of positional parameters assigned to a query correspond exactly to the number of positional parameters declared in that query.
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java

Marc Prud'hommeaux made changes - 02/Apr/07 10:00 PM
Resolution Fixed [ 1 ]
Fix Version/s 0.9.7 [ 12312340 ]
Status In Progress [ 3 ] Resolved [ 5 ]