Should Validator check constraints of proxy subclass in JBoss EAP 6?

Solution Unverified - Updated -

Issue

We use javax.validation Constraints with custom groups to validate some constraints in special circumstances. Consider these three entities:

class Person {
   private Pet pet;

   @Valid
   public Pet getPet() {
     return pet;
   }
}

abstract class Pet {
   private String name;

   @NotNull
   @Size(min=1)
   public String getName() {
   }
}

class Cat extends Pet {
  private String furColor;

  @NotNull(groups=Special.class)
  public String getFurColor() {
    return furColor;
  }
}

When an instance of class Person is loaded which has a Cat as pet it happens that the association to 'pet' is lazy loaded and therefore is a HibernateProxy instance. However, the proxy only extends from class Pet and not from the actual class Cat.

When the validator is applied to the instance of Person with groups Default and Special only the property 'name' of Pet is validated, the property 'furColor' is not validated.

Is there a way, that the Validator will check all constraints of the delegating instance of a HibernateProxy instead of all constraints of the proxy itself?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content