persistence@glassfish.java.net

Re: Do update/delete statements support Collection member declaration and path expressions

From: Michael Bouschen <mbo.tech_at_spree.de>
Date: Thu, 13 Sep 2007 22:17:33 +0200

Hi Farruk,

you are right: the FROM clause of a DELETE or UPDATE operation in the
Java Persistent query language does not support multiple identification
variables. But maybe you can use a subquery to specify the condition for
the collection element:
  DELETE FROM Player p
  WHERE EXISTS (SELECT t FROM p.teams t WHERE t.city = :city)

I'm not sure about the rational, it might have to do with whether the
relevant SQL dialects support multiple identification variables in the
FROM clause of an UPDATE or DELETE.

Regards Michael

> Dear colleagues,
>
> Does EJBQL support the simplified syntax for matching objects to
> update or delete based on the value of an attribute in an element of a
> collection attribute?
>
> I do not see any evidence of it in the spec which is surprising.
>
> As an example the following SELECT query does not seem to have an
> equivalent simplified syntax for UPDATE or DELETE:
>
> SELECT DISTINCT OBJECT(p)
> FROM Player p, *IN (p.teams) AS t
> *WHERE *t.city* = ?1
>
> If as I suspect, it is not supported, then can someone please provide
> a rationale as to why not?
> Perhaps I am missing something obvious.
>
>


-- 
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