Hello Ricardo,
Yes, Cayenne supports that, the easiest option is an `alias()` function in
the Property API:
ObjectSelect.query(Artist.class)
.where(Artist.PAINTING_ARRAY.alias("p1").dot(Painting.PAINTING_TITLE).startsWith("A"))
.and(Artist.PAINTING_ARRAY.alias("p2").dot(Painting.PAINTING_TITLE).startsWith("G"))
.select(context);
On Thu, Oct 2, 2025 at 4:37 AM Ricardo Parada <[email protected]>
wrote:
>
> Hello,
>
> I’m wondering if it’s possible to force a second join to a table. For
> example:
>
> paintings.name like A% AND paintings.name like G%
>
> In a SQL query, this will always return 0 records because a given painting
> cannot start with the letter A and G at the same time. It either starts
> with one or the other.
>
> So if I’m looking for artists that have a painting with its name starting
> with the letter A and another one with the letter G then the SQL would have
> to do a second join.
>
> For example,
>
> SELECT * FROM ARTIST t0
> JOIN PAINTING t1 ON t1.ARTIST_ID = t0.ID
> JOIN PAINTING t2 ON t2.ARTIST_ID = t0.ID
> WHERE t1.NAME LIKE ‘A%’
> AND t2.NAME LIKE ‘G%’
>
> Thanks in advance,
> Ricardo Parada
>
>
>
>
--
Best regards,
Nikita Timofeev