cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <>
Subject Re: Queries with multiple tables and results
Date Wed, 23 May 2012 04:10:29 GMT
I'll chime in with the "you probably aren't doing it the Cayenne way" response. Why do you
want a mixture of two different records in the one result set? I can think of two reasons:

1. You have two tables which represent similar things: Customers and Suppliers. You want to
query them together to get a list of Contacts. In that case modelling them with a common superclass
might be a more helpful approach. Read up on Cayenne inheritance.

2. You have a Contacts table but are trying to optimise the SQL by returning Invoices at the
same time since you know you need to iterate through both. In this case, just query on Contacts
and ignore Invoices. Cayenne will fetch those as you need them and reference them. contact.getInvoices()
will fault them from the database as required.

If you are worried about performance of this approach, prefetching as Michael pointed you
in the docs will solve that.


On 22/05/12 10:58pm, pk_cayenne 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:
> Sent from the Cayenne - User mailing list archive at

Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message