-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: @GroupSequence and group inheritance
PostPosted: Thu Feb 18, 2010 4:15 am 
Newbie

Joined: Wed Feb 17, 2010 6:50 am
Posts: 1
I have some constraints in the model class like this:
Code:
public class User{

   @NotNull
   private String name;

   @NotNull(groups=AfieldCheck.class)
   private String aField;

   @NotNull(groups=AnotherFieldCheck.class)
   private String anotherField;

}

the group definition:
Code:
public interface AfieldCheck{}
public interface AnotherFieldCheck extends Default{}

AnotherFieldCheck extends the default validation group so it checks both name and anotherField
Now I define a group for ordered constraint evaluation
Code:
@GroupSequence({AnotherFieldCheck.class, AfieldCheck.class})
public interface OrderedCheck {}

If I make the below method call:
Code:
validator.validate( user, OrderedChecks.class );

When the validator checks the first group AnotherFieldCheck.class which extends Default.class, the field name of the Default groups it isn't evaluated.

Is it right?


Top
 Profile  
 
 Post subject: Re: @GroupSequence and group inheritance
PostPosted: Thu Feb 18, 2010 9:40 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
No, that's not right. It's a bug - HV-288


Top
 Profile  
 
 Post subject: Re: @GroupSequence and group inheritance
PostPosted: Tue Apr 06, 2010 1:20 am 
Newbie

Joined: Thu Dec 15, 2005 8:31 am
Posts: 10
I think the behavior he is describing is correct. What is point of creating a group that decends from Default? It was my impression that the purpose of decending from Default was to declare that this field should be validated both when the decendent is specified and when Default is the scope, not the other way around. It does not seem to fit the general concept of inheritence. Specificity should never be overridden by generality.

It seems to me the logic should be as follows:

Group decends from Default - All fields annotated with group are validated when Group is specifed AND during default
Group does not decend from Default - All fields annotated with group are validated ONLY when Group is specifed and NOT during default
Fields without group affiliation should be validated ONLY during Default validation scope


Top
 Profile  
 
 Post subject: Re: @GroupSequence and group inheritance
PostPosted: Tue Apr 06, 2010 4:40 am 
Newbie

Joined: Thu Dec 15, 2005 8:31 am
Posts: 10
Well as much as I think I am right ... I just read the spec and that is the behavior. Personally I think it is counter-intuitive but no matter. I was able to accomplish what I needed. Even if it took more steps then necessary.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.