title: When should I use @Basic(optional = false) in JPA 2.0
body: <p>I have a Inheritance with Single Table mapping in JPA, Say Class A and B extends some abstract entity, so I have to make columns from A &amp; B nullable at DB end but if someone is trying to persist A then all fields of A should be not null and i want to enforce this by code.
  Can I use following code to achieve this -  <br>  </p>
  
  <pre><code>@Entity  
  @DiscriminatorValue("1")  
  public Class A extends SomeAbstractEntity{    
       @Basic(optional = false)  
       private String nameOfA;  
  }
  </code></pre>
  
  <p>I read this answer <a href="https://stackoverflow.com/questions/2899073/basicoptional-false-vs-columnnullable-false-in-jpa">@Basic(optional = false) vs @Column(nullable = false) in JPA</a> and thought this may be achievable but wanted to know what is the best way.</p>