Mam 2 encje JPA w relacji one-to-many - Seat i Booking. Chciałbym pobrać Seat po id z Bookings ze statusem "ACTIVE'. Jeśli Booking nie miałby takich Seats to powinno zostać zwrócone Seat z pustą listą Bookings.
Takie query działa w konsoli do SQL:
select * from seats s left join bookings b on b.seat_id=s.id and b.status='ACTIVE' where s.id=1
Przerobiłem je na query do Spring Data JPA:
@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")
Ale dostaję taki błąd:
org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause not allowed on fetched associations; use filters