You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Marc Logemann <li...@logemann.org> on 2009/03/05 11:41:41 UTC

MethodQL completely broken isnt it?

Hi,

since Filter Extension wont work as discussed, i wanted to use  
MethodQL as explained in Chapter 9 Section 5. I used mainly the same  
stuff explained in the docs:

---

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();

---

First of all, when doin this, i am getting a complaint on parameters  
like that:

<openjpa-1.2.0-r422266:683325 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. Native queries only allow the use of positional  
parameters.


Then i tried positional parameters like setParameter(1, "foo");

With that there is no exceptiom but the params parameter of the method  
signature s empty!

public static ResultObjectProvider fooMethod(StoreContext ctx,  
ClassMetaData meta, boolean subclasses,
                                            Map params,  
FetchConfiguration fetch);

Besides all this, i am wondering how to trigger the in-Memory Method  
exaplained in the docs later on. The method here has a different  
signature but somehow i must tell the query to use in-memory right?  
Otherwise the framework will always call the method siganture i showed  
above.

So right now i am not being able to somehow reimplement my custom  
filter extension i used with Kodo back then. MethodQL was my only hope  
to solve all this. Please comment on these bugs.... if they are bugs  
but i dont know how to do something wrong here....

Marc