title: Spring Boot org.hibernate.exception.ConstraintViolationException
body: <p>I am getting .ConstraintViolationException when I try to persist data using the POST REST API.</p>
  
  <p>Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint
    Detail: Failing row contains (null, John Doe, How are you?, I am fine).</p>
  
  <p>I am using @GeneratedValue(strategy = GenerationType.IDENTITY) to auto generate "id" from Hibernate and I am not sure If I am missing any configuration in application.properties. I am using Postgres db. </p>
  
  <p>I tried using GenerationType.AUTO and I was getting hibernate_sequence missing error from postgres.</p>
  
  <p>Thanks!</p>
  
  <h1>POST REST API input using Postman</h1>
  
  <pre><code>            {   
                  "personName": "John Doe",
                  "question": "How are you?",
                  "response": "I am fine"
              }
  </code></pre>
  
  <h1>questionnaries.sql</h1>
  
  <pre><code>            CREATE TABLE questionnaries( 
              id BIGINT PRIMARY KEY,
              personName VARCHAR(255) NOT NULL,
              question VARCHAR(255) NOT NULL,
              response VARCHAR(255) NOT NULL
              );
  </code></pre>
  
  <h1>Questionnarie.java #</h1>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  import javax.validation.constraints.NotNull;
  
  @Entity
  @Table(name = "questionnaries")
  public class Questionnarie {
  
  
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "id")
      private Long id;
  
  
      @Column(name = "personname")
      @NotNull
      private String personname;
  
  
      @Column(name = "question")
      @NotNull
      private String question;
  
      @Column(name = "response")
      @NotNull
      private String response;
  
      public Questionnarie() {}
  
      public Questionnarie(@NotNull String personname, @NotNull String question, @NotNull String response) {
          super();
          this.personname = personname;
          this.question = question;
          this.response = response;
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getPersonname() {
          return personname;
      }
  
      public void setPersonname(String personname) {
          this.personname = personname;
      }
  
      public String getQuestion() {
          return question;
      }
  
      public void setQuestion(String question) {
          this.question = question;
      }
  
      public String getResponse() {
          return response;
      }
  
      public void setResponse(String response) {
          this.response = response;
      }}
  </code></pre>
  
  <h1>application.properties</h1>
  
  <pre><code># ===============================
  # = DATA SOURCE
  # ===============================
  # Set here configurations for the database connection
  
  spring.datasource.jndi-name=java:jboss/datasources/test_data_source
  
  # ===============================
  # = JPA / HIBERNATE
  # ===============================
  # Show or not log for each sql query
  spring.jpa.show-sql=true
  
  # Allows Hibernate to generate SQL optimized for a particular DBMS
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
  </code></pre>