0

I'm running an application simulates selling air plane tickets.
Using a simple schema (1-n):

SEAT
------
id_seat
description
position

BOOKING
---------
id
customer
id_seat

I'd like to produce a Query using either JPA API or Criteria which provides me a list of all available SEATs. That is, all SEAT Objects which do not exist (not booked) in the BOOKING table. (SEAT.id_seat = BOOKING.id_seat)

Can anybody give me a clue which is the best option to produce such a Query?

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Max Korn
  • 275
  • 7
  • 18

1 Answers1

1
select seat from Seat seat 
where seat.id not in (
    select seat2.id from Booking booking 
    inner join booking.seat seat2)
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255