Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-07 Thread Gunnar Morling
2010/10/6 Emmanuel Bernard > > Too sad, that javax.validation.ValidatorContext is not defined as > > public interface ValidatorContext > { > > } > > If it were, we wouldn't need a dedicated method > HibernateValidatorFactory#usingHibernateContext(), but > HibernateValidatorFactory could be define

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-06 Thread Emmanuel Bernard
> > Too sad, that javax.validation.ValidatorContext is not defined as > > public interface ValidatorContext > { > > } > > If it were, we wouldn't need a dedicated method > HibernateValidatorFactory#usingHibernateContext(), but > HibernateValidatorFactory could be defined as > > public interf

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Max Rydahl Andersen
On Oct 5, 2010, at 17:43, Emmanuel Bernard wrote: > If we /really/ want stopAfterNFailures, I'd go straight to it. It's easy to > implement and will confuse people less. But the number of failures will be a > guaranteed to be above int (if there are enough ;) ) and the order will be > unspecif

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Gunnar Morling
Hi, answers inline. Gunnar 2010/10/5 Emmanuel Bernard > Not rebuild the factory, reusing it. > > regularValidator = factory.getValidator(); > failFastValidator = factory.unwrap(HibernateValidatorFactory.class) >.usingHibernateContext() >

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Emmanuel Bernard
Not rebuild the factory, reusing it. regularValidator = factory.getValidator(); failFastValidator = factory.unwrap(HibernateValidatorFactory.class) .usingHibernateContext() .failFast(true)

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Sanne Grinovero
2010/10/5 Hardy Ferentschik : > I was about to ask what you've been smoking ;-) ROFL, It's always a lot of fun to follow this list :) Cheers, Sanne > > On Tue, 05 Oct 2010 17:45:23 +0200, Emmanuel Bernard > wrote: > >> oops reading Gunnar's answer, I'm probably answer the wrong question :) >> >>

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Hardy Ferentschik
I was about to ask what you've been smoking ;-) On Tue, 05 Oct 2010 17:45:23 +0200, Emmanuel Bernard wrote: > oops reading Gunnar's answer, I'm probably answer the wrong question :) > > On 5 oct. 2010, at 17:23, Emmanuel Bernard wrote: > >> public doStuff(@Param("name") String name, @Param("co

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Hardy Ferentschik
Ok. Makes sense. But why not overloading the validate methods? This way you can with the same Validator dynamically change the maximum number of failing constraints. In Emmanuel's case you would have to rebuilt the factory. --Hardy On Tue, 05 Oct 2010 17:42:41 +0200, Gunnar Morling wrote:

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Emmanuel Bernard
oops reading Gunnar's answer, I'm probably answer the wrong question :) On 5 oct. 2010, at 17:23, Emmanuel Bernard wrote: > public doStuff(@Param("name") String name, @Param("command") Object command) { >... > } > > On 5 oct. 2010, at 16:07, Hardy Ferentschik wrote: > >> Where exactly do yo

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Emmanuel Bernard
If we /really/ want stopAfterNFailures, I'd go straight to it. It's easy to implement and will confuse people less. But the number of failures will be a guaranteed to be above int (if there are enough ;) ) and the order will be unspecified though today we do breadth-first I believe which is what

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Gunnar Morling
I'd put it at the same place as the boolean parameter in Emmanuel's prototype: when creating the ValidatorFactor/Validator (e.g. inHibernateValidatorConfiguration). So "parameter" was not meant as in "method parameter" but more as in "configuration attribute" :-) 2010/10/5 Hardy Ferentschik > Wh

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Emmanuel Bernard
public doStuff(@Param("name") String name, @Param("command") Object command) { ... } On 5 oct. 2010, at 16:07, Hardy Ferentschik wrote: > Where exactly do you want to add the parameter? To the > Validator.validateXYZ() methods? > > > On Tue, 05 Oct 2010 15:54:10 +0200, Gunnar Morling > w

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Hardy Ferentschik
Where exactly do you want to add the parameter? To the Validator.validateXYZ() methods? On Tue, 05 Oct 2010 15:54:10 +0200, Gunnar Morling wrote: > Hi, > > a use case might be a data-centric application, where you for performance > reasons don't want to validate graphs completely once a fai

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-05 Thread Gunnar Morling
Hi, a use case might be a data-centric application, where you for performance reasons don't want to validate graphs completely once a failure occured, but don't want to face the user with single validation errors one after the other either. Specifying the validation order would surely be useful.

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-04 Thread Gunnar Morling
Hi, I like the idea. Emmanuel's performance test showed an execution time per validation of 11 vs. 74 ms on my system, so there seems to be some potential. Instead of having a "failFast" flag one could also introduce a numeric parameter to control, when validation should stop. A value of "1" would

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-04 Thread Emmanuel Bernard
That or slowish validations. One typical use case is that: if ( validator.validate(customer, StraightToValidationScreen.class).size() >0 ) { //manual process } else { //automatic process } BTW, I've committed a non scientific perf test that shows an average of 5x perf improvement on an obj

Re: [hibernate-dev] Fail fast feature for Hibernate Validator

2010-10-04 Thread Hardy Ferentschik
What would be the usecase? Saving time in large object graphs where I am only interested in whether there is a failure at all? You really need LARGE object graphs to make this worth while. On Mon, 04 Oct 2010 15:45:34 +0200, Emmanuel Bernard wrote: > http://github.com/emmanuelbernard/hibe