Hi,
This is concerning a subset of sequence diagram: how to what seat types are available (window, aisle, 1st class, coach class), and how to book a seat for a given flight.
Two tables are involved and I use entity bena (since it requires us to use
J2EE.)
table A: Flight, Plane, Plane Type
so that with any given flight, I know the plane it is assigned. Say, for flight 123, it is assigned to a Boeing 737.
There are several table in the following SEAT_PLAN structure, one for each plane type. The reason I use several tables as oppose to one big table is to distribute the load, so that the 600 users do not hit the same table.
Say, the following is BOEING737_SEATPLAN: (so that only flights assigned to a Boeing 737 interact with this table, thus distribute the load)
FlightNumber, SeatNumber, Reserved, SeatType
This structure allows user to query if certain seat type (window, aisle, 1st class, coach) is still available for a given flight in EJB-QL:
SELECT DISTINCT SEATTYPE FROM BOEING737_SEATPLAN WHERE FLIGHT_NUMBER = ?1 AND RESERVED = 'N'.
My problem comes in when I want to book a seat. Since the requirement says we must use J2EE, so I need to use entity bean. But with EJB-QL, it returns a list of seats to book (I do not think there is a way to return one object that satisfying the criteria):
SELECT Object FROM BOEING737_SEATPLAN WHERE FLIGHT_NUMBER = ?1 AND SEAT_TYPE = ?2 AND RESERVED = 'N'.
This returns a list of Seat object, but I only need one. Of course, I could randomly pick one from the list, and call object.Reserved(true) to update the RESERVED column to true. But that sounds like a little overkill.
Any comment?
Thanks,
Yan