I use Validator 4.1.0 with annotations together with hibernate. I realized that the validation events only get fired when I save or update the entity in question.
However, in the following scenario the validation events don't fire:
EntityA is associated by means of a collection to EntityB as follows:
Code:
@ManyToMany(fetch = FetchType.LAZY)
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@Size(min = 1)
public Set<EntityB> getBs() {
return bs;
}
The @Size(min = 1) annotation only is considered when I save/update EntityA directly. But when I call
Code:
entityA.getBs().remove(theLastOfTheBs);
session.commit();
the validation event does not get fired. It get's fired however when I call
session.save(entityA);.
Is there a way to fire the event without the unnecessary call to save()?
Conny