Hi,
The Java Persistence query language supports JOINs to navigate
relationships and subqueries. I'm not sure what your query is supposed
to select, the following query returns customers having either no orders
or the orders do not have an item called 'apple':
SELECT c FROM Customer c WHERE c.customerId NOT IN
(SELECT c2.customerId FROM Customer c2 JOIN c2.orders o JOIN o.items i
WHERE i.itemName = 'apple')
Regards Michael
> Hi, i am new to JPA, just wonder how to write a very complex query including
> multiple tables and subquery, say "
> select *
> from customer c, order o, item i
> where c.customerId
> not in (select c.customerId
> from customer c, order o, item i
> where item.itemName !='apple'
> )
>
> is there a easy way to write complex query???
>
> Thanks a lot.
>
>
>
--
Tech_at_Spree Engineering GmbH Tel.: +49/(0)30/235 520-33
Buelowstr. 66 Fax.: +49/(0)30/217 520-12
10783 Berlin mailto:mbo.tech_at_spree.de
Geschaeftsfuehrung: Anna-Kristin Proefrock
Sitz Berlin, Amtsgericht Charlottenburg, HRB 564 52