[hibernate-dev] On possible extensions for the validator

Emmanuel Bernard emmanuel at hibernate.org
Mon Oct 18 03:48:16 EDT 2010


On 16 oct. 2010, at 10:56, Dag Hovland wrote:

> On 15/10/10 13:33, Emmanuel Bernard wrote:
> (...)
>> That being said, I wonder whether you can write your approach atop a generic class-level constraint @CrossValidation that would look for the properties annotations and behave as expected. That would be a nice way to offer both world to the users. You will need to "group" cross field constraints though: as I see it on the paper, you can only have one group of cross level constraint for a given constraint type per class.
> 
> I do not really understand this. Can you give an example?

class BrokenModel {
   @AtLeastOneNotNullAmongst(Group1.class)
   A getA() { ... };
   @AtLeastOneNotNullAmongst(Group1.class) @AtLeastOneNotNullAmongst(Group2.class)
   B getB() { ... };
   @AtLeastOneNotNullAmongst(Group2.class)
   C getC() { ... };
}

A or B must be not null and B or C must be not null.



More information about the hibernate-dev mailing list