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

Hardy Ferentschik hibernate at ferentschik.de
Thu Feb 19 05:45:31 EST 2009


On Thu, 19 Feb 2009 11:38:32 +0100, Emmanuel Bernard  
<emmanuel at hibernate.org> wrote:

>
> On  Feb 19, 2009, at 10:52, Hardy Ferentschik wrote:
>
>> On Wed, 18 Feb 2009 18:44:52 +0100, Emmanuel Bernard  
>> <emmanuel at hibernate.org> wrote:
>>
>>> 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?
>>
>> I agree there is a problem. I don't like the idea of getting two  
>> constraint violations though.
>> Would it be an alternative to let ConstraintViolation.getPropertyPath()  
>> return an array of
>> path strings?
>
>
> That makes ConstraintViolation much harder to use.

Agreed. You could also introduce an additional method  
ConstraintViolation.alternativePropertyPaths().
In the case where you don't care you can just use getPropertyPath and get  
'a' path to the invalid object.
If your usecase require more information (and that's probably quite rare)  
you can use alternativePropertyPaths.
The API gets more complex, but it's not harder to use for the most common  
cases.

--Hardy





More information about the hibernate-dev mailing list