So does it mean that constraints on generic types is not properly supported in hibernate implementation for regular beans? I believe it is valid case when you have constrained generic type like this:
private GenericBean2<@NotNull Integer> f1;
This way you can extend constraints... For example, I have bean with some standard constraints. At some point I want to have constraints to be extended without declaring another class. I can do it just by using TYPE_USE annotations/constraints. The same way it is used for List, Map, etc. What makes it more complicated in this example is that type T is referenced in multiple properties and passed to another type (GenericBean). And in the end GenericBean f1 property will be required property. From value extractor I understand that it only can handle single value per type. Which is not the case in reality. For instance, it can be this way where we have multiple properties with the same type:
public class GenericClass<T> {
@Max(5)
private T fieldAndMethodConstraints;
@Max(4)
private T fieldConstraint;
private T methodConstraint;
private T noConstraints;
BTW, If I remove my value extractors from this solution I get following error: javax.validation.ConstraintDeclarationException: HV000197: No value extractor found for type parameter 'T' of type org.hibernate.validator.bugs.GenericBean2. Which points me to this path - declare value extractor. |