I have Seat and Booking JPA entities in one-many relation. I want to fetch Seat by id with Bookings with status "ACTIVE". If Seat doesn't have any Bookings with this status, Seat with empty Bookings list should be returned.
The following query works in SQL console:
select * from seats s left join bookings b on b.seat_id=s.id and b.status='ACTIVE' where s.id=1
I translated it to Spring Data JPA query:
@Query("select s from Seat s left join fetch s.bookings b on b.seat.id=s.id and b.status='ACTIVE' where s.id = :seatId")
But i got such error:
org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause not allowed on fetched associations; use filters