openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Prud'hommeaux <mprud...@apache.org>
Subject Re: Using MethodQL
Date Tue, 26 Jun 2007 19:42:31 GMT

MethodQL is not a widely-used feature, so I wouldn't be surprised if  
there might be a bug in there somewhere.

What does your getByName() method look like? Also, if you just  
exclude the parameter declaration from the code, do you still get the  
same exception?

> BTW, the UserGuide does not give examples or go into details on a  
> lot of the
> features. Any other documentation available besides the UserGuide and
> Javadoc?

The user guide and javadoc are the 2 main sources of documentation.  
There are occasional examples on the wiki at openjpa.apache.org, but  
there aren't that many at this time.

Are there other features that you find under-documented? We are  
always looking to improve the docs.



On Jun 25, 2007, at 3:31 PM, e33238 wrote:

>
> I'm trying to figure out how to use MethodQL. This is the example  
> given in
> the UserGuide:
>
> // the method query language is 'openjpa.MethodQL'.
> // set the query string to the method to execute, including full  
> class name;
> if
> // the class is in the candidate class' package or in the query  
> imports, you
> // can omit the package; if the method is in the candidate class,  
> you can
> omit
> // the class name and just specify the method name
> OpenJPAEntityManager oem = OpenJPAPersistence.cast(emf);
> OpenJPAQuery q = oem.createQuery("openjpa.MethodQL",
> "com.xyz.Finder.getByName");
>
> // set the type of objects that the method returns
> q.setResultClass(Person.class);
>
> // parameters are passed the same way as in standard queries
> q.setParameter("firstName", "Fred").setParameter("lastName", "Lucas");
>
> // this executes your method to get the results
> List results = q.getResultList();
>
>
> I created a Person class (that has "firstName" and "lastName") and  
> a Finder
> class that has a static getByName() method. But I got an error when
> q.getResultList() is called:--
>
> <0.9.7-incubating nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: The parameter  
> name or
> position "firstName" passed to execute() is not valid.  All map  
> keys must be
> a declared parameter name or a number matching the parameter position.
>
> Any suggestions on what I may be doing wrong?
>
> BTW, the UserGuide does not give examples or go into details on a  
> lot of the
> features. Any other documentation available besides the UserGuide and
> Javadoc?
>
> Thanks!
> -- 
> View this message in context: http://www.nabble.com/Using-MethodQL- 
> tf3979366.html#a11296891
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Mime
View raw message