Re: How to build Exists Expression with a sub expression on the child entity?

Nikita Timofeev <[email protected]> Sat, 27 Sep 2025 20:26:15 +0400
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAMi+qzBXRme+CMnwGB89Sj6gaFOtDS+mRt_PQBrt8zWt6-FYhw@mail.gmail.com>
--0000000000000bc941063fcade12
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Ricardo,

Yeah, there's not much info on that since that's a new API. `exists()` is a
terminal operator that converts the whole expression to an EXISTS query.

So it would be something like this in your
example: Artist.PAINTINGS.dot(Painting.NAME).like("painting%").exists()


On Fri, Sep 26, 2025 at 8:31=E2=80=AFPM Ricardo Parada <[email protected]=
alid>
wrote:

> Hi all,
>
> Another question I have is regarding EXISTS expressions.  I=E2=80=99m not=
 sure if
> I=E2=80=99m using the API correctly, but I was thinking it would be somet=
hing like
> this.  Using the entities from the Tutorial, let=E2=80=99s say I want to =
fetch the
> Artist=E2=80=99s that have a painting starting with the letter =E2=80=98G=
=E2=80=99:
>
> Expression e =3D Artist.PAINTINGS.exists(Painting.NAME.like(=E2=80=9CG%=
=E2=80=9D));
>
> But I=E2=80=99m getting a syntax error.



--=20
Best regards,
Nikita Timofeev

--0000000000000bc941063fcade12--