Hello everybody. After almost a year of development of project that uses JPA/Eclipselink we have to route all our queries to db tables and views via oracle packages. So the question is: is it possible in eclipselink to access to tables using customized query templates?
Instead of "SELECT NAME, SURNAME FROM SCHEME1.USER WHERE ID = ?" generate "SCHEME1.PACKAGENAME1.FUNCTION1(?)" for select and same for other queries - create/update/delete?
I didn't found something alike in raw JPA, maybe it is possible using eclipselink API?

Interesting, the very same thing I was unsuccessfully trying a year ago.

In the end my solution was to directly call procedures and flush cache after every write. Very cumbersome. So if you manage to get it working I'd like to know how. Also I will try again, maybe stuff got fixed and I know a bit more.

Now I can clearly see the default ReadAllQuery is used. Was the same 1 year ago, is the same still.

Might be descriptor cannot get those annotated named procedures? There is never any error, just calling of default sql query on a table.

Can someone point me to a working example of this?

edit: well I guess this is just impossible to do as I imagined. If I write/generate direct procedure calls then maybe, but you can't use named procedures/functions in descriptorCustomizer.

Also another problem is cache refreshing anyway since some inserts might do a little of their own tinkering so everything is redundant anyway. Turn off cache, use wrapped objects to query data and its done.

Where are you using this code, what error do you get? To override the default readAll operation you need to set this query in the DescriptorQueryManager. Include your complete DescriptorCustomizer code.

In general, it is normally the insert, update, delete, readObject queries that are override, as these are specific queries. The readAll query would only override a dynamic query for all instances (no where clause, not hints). JPA has some different defaults, so you may need to set the distinctState of the query. For a readAll query it would be easier to just execute a named query that calls the stored procedure.

That code is directly in the customizer descriptor. I am guessing its not processing annotated procedures.

The thing works when I call procedures directly, BUT there are some things I am not able to do in that framework. I want some of the power of calling named stored procedures I cannot get there plainly calling em. So I ended up calling procedures directly.

Also funny thing is to use setDefaultReadAllQueryRedirector and create a new readAllQuery inside it. You will get immediate stack overflow (recursion).