JPA - Override bean validation in joined-strategy inheritance -


I have three JPA entities: A, B and C. Is it possible to override the Bean Validation barrier in subclasses? For example, I would like to get a @not tap in a field and get a non-obligation in the same area for C.

I was thinking of doing this using the Bean Validation group, but I do not know how to define B with another group and with C, the second group should be valid.

Code to clarify the problem:

  @Entity @Inheritance (strategy = inheritance type. Jind) ... public abstract class A {... @ column (Name = "field") private integer field; ...} @Entity Public Class B expanded in a {... // @ NotNull field ...} @Antity LocalCc in a {... // @ Null field in ...}    

I think I came to a solution to read this second question about conditional bean verification I am ..

It has not been tested yet, but I think it could work.

The solution code:

  @Entity @Inheritance (strategy = InheritanceType.JOINED) ... Public abstract class A {... @ column (name = "FIELD ") Private Integrity Field; ...} @Entity Public Class B's extension A {... @transient @AssertTrue is private boolean ValidClassA () {returns (getField ()! = Null); // valid is not valid ...}} @Entity public class C extension A {... @Transient @AssertTrue is private boolean ValidClassA () {returns (getField () == blank); // valid tap} ...}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -