[hibernate-issues] [Hibernate-JIRA] Commented: (HV-466) Avoid repeated validation of constraints in certain type hierarchies

Kevin Pollet (JIRA) noreply at atlassian.com
Wed Apr 20 04:30:59 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42114#action_42114 ] 

Kevin Pollet commented on HV-466:
---------------------------------

I'm not really sure that just keep track of already processed interface will work. With the current implementation I think that the problem only appear for constraints hosted on an interface Foo which belongs to the groups Foo (eg. constraints which do not declare a group or the Default group). I have the following example in mind (here only {{A#getA2()}} will be evaluated twice):

{code}
interface A {
   @NotNull(groups = Foo.class) 
   String getA1();

   @NotNull 
   String getA2();
}

@GroupSequence({B.class, Foo.class})
class B implements A {
    
    String getA1() {
	return null;
    }

    String getA2() {
	return null;
    }
}

class C extends B implements A {
		
}
{code}

IMO, keeping track of only interface processed for the default group will works, maybe it's already your thinking ;). WDYT ?

> Avoid repeated validation of constraints in certain type hierarchies
> --------------------------------------------------------------------
>
>                 Key: HV-466
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-466
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: engine
>            Reporter: Gunnar Morling
>            Priority: Minor
>             Fix For: 4.x
>
>
> Let there be the following type hierarchy where the same interface is implemented by two types in an inheritance hierarchy:
> {code:java}
> public interface A {
> 		
> 	@NotNull
> 	String getA();
> }
> 	
> public class B implements A {
> 	public String getA() {
> 		return null;
> 	}
> }
> public class C extends B implements A {
> 		
> }
> {code}
> When validating an instance of {{C}} the {{@NotNull}} constraint on {{A#getA()}} is evaluated twice when traversing the type hierarchy of {{C}} in {{ValidatorImpl}}.
> This seems to be against the BV spec. which says in chapter 3.5: 
> {quote}
> Note that this [algorithm] implies that a given validation constraint will not be processed more than once per validation.
> {quote}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list