I'm developing java application with JPA. In the application I have Rooms and Reservations :
@Entity
@Table(name = "RESERVATIONS")
public class Reservation {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private Room room;
private LocalDate checkInDate;
private LocalDate checkOutDate;
//getters setters
}
I want to validate that the room cannot be booked twice for the same period.
Any ideas how I can do that?