I have an hibernate entity which contains two dates: start and finish.
@Entity
public class MyEntity{
private Date start
private Date finish;
...
@Temporal(TemporalType.DATE)
@Column(name = "start", nullable = false)
public Date getStart() {
return start
}
@Temporal(TemporalType.DATE)
@Column(name = "finish", nullable = false)
public Date getFinish() {
return finish;
}
}
I would like to introduce a constraint that says start must be before finish,
can I do this kind of validation/check in the hibernate entities in order to avoid to write invalid data in my table?
If yes, how?
My guess is not, probably I have to write a trigger.. is it right? any better ideas?