How to map value dynamically for an entity's field

I need to dynamically allocate value at creation time for an entity by fetching value from another table. Consider the below scenario where I have two classes - Student & Batch. While inserting new record in Student table at the time of creation, considering the fact that only one batch can be active at the given time, I need to set the current active batch by checking ‘Active’ field true from Batch table. And this has to be done dynamically. Please suggest me some best usage of hibernate to handle this.

Student.java

public class Student {

@Id
@GeneratedValue(Strategy = GeneratedType.Identity)
private Integer id;

private String name;

private Date DOB;

@ManyToOne
@JoinColumn(name = "Student_Batch", nullable=false)
private Batch allocatedBatch;

.....Getter and setter methods....
}

Batch.java

public class Batch {

@Id
@GeneratedValue(Strategy = GeneratedType.Identity)
private Integer id;

private String name;

private Date startDate;

 @ColumnDefault("false")
private boolean Active;

@OneToMany(mappedBy = "allocatedBatch", cascade = {CascadeType.PERSIST, CascadeType.REMOVE)
private Student student;

.....Getter and setter methods....
}