How to send ArrayList or Sets<Integer> as list filtering in Request Body or URL in PUT Request

Viewed 224

I'm trying to write a controller that will function as multiple seat reservation.The Integers list is used for filtering. My Entity looks like this:

@Entity
@Id
private movieId;
private String movieName;
private String cinemaName;
private String cinemaHall;
private Intger seatingPlace;
private boolean booked;

How Can I pass list or sets in request body to access multiple update seatingPlace. Did I modyfing Enity or connect in smthing relation?

Acutally my multipleUpdate API works using JPA Query findByMovieNameAndCinemaNameAndcinemaHall and return me list wchich I checking isnt Empty and cheking (field boolean booked) if true so ok u can booked them. And after that i want filter by passing List seatingPlace and change boolen to false.

1 Answers

Based on my understanding of your requirements, a possible solution could be creating another entity (table) MovieSeatReservation and creating a One to Many relationship from your Entity. It could look like this: (You can replace Entity class name with your real entity name)

@Entity
public class Entity {
    
    @Id
    @GeneratedValue
    private Long movieId;
    private String movieName;
    private String cinemaName;
    private String cinemaHall;
    @OneToMany
    private List<MovieSeatReservation> reservedSeatsStatus;

    // getters and setters
}

@Entity
public class MovieSeatReservation {

    @Id
    @GeneratedValue
    private Long id;
 
    private boolean isReserved;
 
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "movie_id")
    private Entity entity;

    // getters and setters

}
Related