cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Queries based on relationship size
Date Thu, 21 Feb 2008 13:55:56 GMT
EJBQL query with outer joins should help:

1. select c from Customer c JOIN c.orderHistory

    (inner join filters customers with Orders, so this is like a  
regular SelectQuery)

2. select c from Customer c LEFT JOIN c.orderHistory d WHERE d is null

    (outer join combined with the WHERE clause should allow fetching  
customers with no orders)

Two caveats: we still need to add pagination support per CAY-963; I  
may have taken a few _temporary_ shortcuts in the EJBQL parser that  
may cause trouble with flattened relationships, so let me know if you  
run into problems.


On Feb 21, 2008, at 3:05 AM, Kevin Menard wrote:

> Greetings,
> I'm running into a little difficulty performing a query that I think
> comes up often enough that it should be fairly straightforward.
> I have a schema similar to the following:
> Customer <--- BillingInfo <--- Order
> I've mapped the read-only relationship "orderHistory" from Customer to
> Order.
> Now I'd like to perform two queries.  One for customers with orders  
> and
> one for customers without.  I'd rather not filter in the app itself
> because I'd like to paginate the result lists.
> Is there a way to do this without resulting to an SQLTemplate query?
> Thanks,
> Kevin
> -- 
> Kevin Menard
> Servprise International, Inc.
> Remote reboot & power control for your network
>                  +1 508.892.3823 x308

View raw message