I have inheritance with displaying a single table in JPA, Say Class A and B extends some abstract object, so I need to make columns from A and B nullified at the end of DB, but if someone tries to save A, then all fields of A should be not null, and I want to ensure its execution using code. Can I use the following code for this -
@Entity @DiscriminatorValue("1") public Class A extends SomeAbstractEntity{ @Basic(optional = false) private String nameOfA; }
I read this answer @Basic (optional = false) vs @Column (nullable = false) in JPA and thought it might be achievable, but I wanted to know what the best way is.
Premraj
source share