Hi Pierre

For that cases with queries with many tables I know about  two options:


Option 1:
Coding an store procedure in you database that includes your query and then
invoque the procedure recovering the composed results from two or more
tables, someway like this:


ProcedureQuery query = new ProcedureQuery("YOURPROCEDURE");
// Set "IN" parameter values
query.addParameter("THEPARAM1", ID1);
// run query
QueryResponse result = getDataContext().performGenericQuery(query);
// QueryResponse result = performNonSelectingQuery(query);
// read OUT parameters
List outList = result.firstList();
if (outList.size() > 0) {
Map outParameterValues = (Map) outList.get(0);
Object[] r = outParameterValues.values().toArray();
 return r;
}
return null;



Option 2:
Using SQLTemplate class:


 String pgTemplate = "SELECT *"
                + " FROM table1, table2 WHERE"
                + " ID1 = ID2  AND ID1=X"

        SQLTemplate query = new SQLTemplate(Observacion.class, pgTemplate);
        query.setFetchingDataRows(true);
        //query.setFetchLimit(100);
        //query.setTemplate(PostgresAdapter.class.getName(), pgTemplate);
        List list = performQuery(query);


Best Regards

EMERSON

On Tue, May 22, 2012 at 2:58 PM, pk_cayenne <pierre.kou...@uhb.fr> wrote:

> Hi,
> Unfortunatly i'm not referring to an "inner join" .
>
> What i see in the documentation is that i can  only fetch data from a
> *single table   * with  the /SelectQuery(Class<?> objectClass, Expression
> e)/.
>
> But in my queries I have at least two tables. I don't how to get a resulset
> like as list.
> Something like  Object[] result = context.performQuery("myQuery").
>
>  I don't know if what I'm saying is understandable.
>
>
> --
> View this message in context:
> http://cayenne.195.n3.nabble.com/Queries-with-multiple-tables-and-results-tp4006413p4006594.html
> Sent from the Cayenne - User mailing list archive at Nabble.com.
>

Reply via email to