Skip to content

Bug: Booking ID is null when creating bookings in MovieTicketBookingSystem #227

Open

Description

@ankit-git00

Problem

When creating a booking in the MovieBookingService, the booking ID is never set, resulting in a null ID value. This is visible when trying to print the booking ID in the demo.

Root Cause

In BookingManager.createBooking(), the BookingBuilder is instantiated without calling .setId():

Booking booking = new Booking.BookingBuilder()
        .setUser(user)
        .setShow(show)
        .setSeats(seats)
        .setTotalAmount(totalAmount)
        .setPayment(payment)
        .build();  // ID is never set!

Since setId() is never called, the id field in the builder remains null, and the Booking object is created with a null ID.

Impact

  • booking.getId() returns null
  • Demo output shows: Booking ID: null
  • This makes it impossible to track or retrieve bookings by ID

Expected Behavior

Each booking should have a unique ID automatically generated upon creation.

Solution

Generate a unique booking ID using UUID.randomUUID().toString() before building the Booking object.

Files Affected

  • solutions/java/src/movieticketbookingsystem/BookingManager.java

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions