I have this following entity
public class Recruitment implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@NotNull
@Column(name = "start_date", nullable = false)
private Instant startDate;
@NotNull
@Column(name = "end_date", nullable = false)
private Instant endDate;
@Enumerated(EnumType.STRING)
@Column(name = "status")
private Status status;
@ManyToOne
private Candidate candidate;
}
If I have a record that a particular Recruitment record has startDate for a candidate suppose January 1st 2023 and endDate january 31st 2023.
if I want to add another recruitment record for the same candidate and if I select the start date between January 1st to January 31st I want to throw an exception.
How can I get the data between startDate and endDate Column date range?