title: @NotNull annotation does not translate to not null constraint in schema generation
body: <p>According to hibernate validator reference documentation - Section <strong>11.1.1. Database schema-level validation</strong> (<a href="https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-checkconstraints-db" rel="nofollow noreferrer">https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-checkconstraints-db</a>),</p>
  
  <blockquote>
    <p>Out of the box, Hibernate ORM will translate the constraints you have
    defined for your entities into mapping metadata. For example, if a
    property of your entity is annotated @NotNull, its columns will be
    declared as not null in the DDL schema generated by Hibernate ORM.</p>
  </blockquote>
  
  <p>But when I annotate my fields with @NotNull, I'm not getting the schema level constraints automatically.</p>
  
  <p>I tried setting <code>Environment.HBM2DDL_AUTO</code> to <code>update</code> and <code>create</code> but neither one works in generating the database constraints.</p>
  
  <p>Even though hibernate by default has the <code>hibernate.validator.apply_to_ddl</code> set to <code>true</code>, I even tried setting that manually - </p>
  
  <pre><code>settings.put("hibernate.validator.apply_to_ddl", true);
  </code></pre>
  
  <p>But none of these options seems to work for me. </p>
  
  <p>My domain class</p>
  
  <pre><code>package com.praveen.domain;
  
  import javax.persistence.Entity;
  import javax.validation.constraints.NotNull;
  
  import lombok.Data;
  
  @Entity
  @Data
  public class Stakeholder extends MyPersistent {
  
      @NotNull
      private String clientCode;
  
      @NotNull
      private String gender;
  }
  </code></pre>
  
  <p>MyPersistent class</p>
  
  <pre><code>package com.praveen.domain;
  
  import java.io.Serializable;
  
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.MappedSuperclass;
  
  import lombok.Getter;
  import lombok.Setter;
  
  @MappedSuperclass
  @Getter
  @Setter
  public class MyPersistent implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  }
  </code></pre>
  
  <p>The code I'm using to get the session factory is</p>
  
  <pre><code>    private static SessionFactory getSessionFactory() {
          if (sessionFactory == null) {
              try {
                  StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
  
                  Map&lt;String, Object&gt; settings = new HashMap&lt;&gt;();
                  settings.put(Environment.DRIVER, Driver.class.getName());
                  settings.put(Environment.URL, "jdbc:mysql://localhost:3306/hibernate_test?"
                          + "zeroDateTimeBehavior=CONVERT_TO_NULL&amp;"
                          + "createDatabaseIfNotExist=true&amp;"
                          + "useSSL=true&amp;"
                          + "verifyServerCertificate=false&amp;"
                          + "autoReconnect=true");
                  settings.put(Environment.USER, "root");
                  settings.put(Environment.PASS, "");
                  settings.put(Environment.DIALECT, MySQL55Dialect.class);
                  settings.put(Environment.HBM2DDL_AUTO, "update");
                  settings.put(Environment.SHOW_SQL, false);
  
                  // HikariCP settings
                  settings.put("hibernate.hikari.connectionTimeout", "20000");
                  settings.put("hibernate.hikari.minimumIdle", "5");
                  settings.put("hibernate.hikari.maximumPoolSize", "20");
                  settings.put("hibernate.hikari.idleTimeout", "300000");
  
                  registryBuilder.applySettings(settings);
                  registry = registryBuilder.build();
                  MetadataSources sources = new MetadataSources(registry);
                  sources.addAnnotatedClass(Stakeholder.class);
  
                  Metadata metadata = sources.getMetadataBuilder().build();
                  sessionFactory = metadata.getSessionFactoryBuilder().build();
              } catch (Exception e) {
                  e.printStackTrace();
                  shutdown();
              }
          }
          return sessionFactory;
      }
  </code></pre>