[hibernate-dev] [Bean Validation] Same instance validated only once and determinism

Emmanuel Bernard emmanuel at hibernate.org
Wed Feb 18 12:44:52 EST 2009


I would like to revive the subject of reaching the same instance  
multiple times in an object graph.

Assuming the following example

A |-> C -> B
     |-> D -> B

Each arrow is an association marked as @Valid

Today, the second time an instance is reached, it is ignored.
So assuming B is invalid we can have c.b is invalid OR d.b is invalid.  
I am getting more and more uncomfortable with that non-determinism.

Dhanji was not bothered arguing that in this case, a user can define  
the order using groups. It's actually not possible as the same  
constraint on B share the same groups definition.

An alternative proposal would look like that.

For a given object graph branch, the same instance cannot be validated  
several times.
This would lead to the validation of the same object several times  
provided it is in different branches

in the previous example, we would have two constraint violation reports:
  - c.b is invalid
  - d.b is invalid

Can you tell me on which side you are?



More information about the hibernate-dev mailing list