title: (Hibernate) java.sql.SQLException: Field 'xxxx' doesn't have a default value
body: <p>Hibernate is throwing the following exception:</p>
  
  <pre><code>Caused by: java.sql.SQLException: Field 'catVerb_id' doesn't have a default value
  </code></pre>
  
  <p>People say that the problem is with my PKs that haven't the AUTO_INCREMENT statement, however you can see that I've done this in my database and the issue continues. So, I brought my classes and my database implementations. </p>
  
  <p>I think my problem is with the testing class... Somebody could show me how do I test this? </p>
  
  <p>(Yes, some words are in Portuguese, but you can understand).</p>
  
  <p>CategoriaVerbete</p>
  
  <pre><code>@Entity
  @Table(name="verbete_categoria")
  public class CategoriaVerbete implements Serializable{
      private long id;
      private String nome;
      private String descricao;
      private int serie;
      private Set&lt;Verbete&gt; verbetes = new HashSet&lt;Verbete&gt;();
      private Set&lt;SignificadosVerbete&gt; significados = new HashSet&lt;SignificadosVerbete&gt;();
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name="catVerb_id")
      public long getId() {
          return id;
      }
      public void setId(long id) {
          this.id = id;
      }
  
      ...
  
      @OneToMany(cascade = {CascadeType.ALL})
      @JoinColumn(name="catVerb_id", nullable = true) 
      public Set&lt;Verbete&gt; getVerbetes() {
          return verbetes;
      }
      public void setVerbetes(Set&lt;Verbete&gt; verbetes) {
          this.verbetes = verbetes;
      }
  
      @OneToMany(cascade = {CascadeType.ALL})
      @JoinColumn(name="catVerb_id", nullable = true)
      public Set&lt;SignificadosVerbete&gt; getSignificados() {
          return significados;
      }
      public void setSignificados(Set&lt;SignificadosVerbete&gt; significados) {
          this.significados = significados;
      }
  
  }
  </code></pre>
  
  <p>Verbete</p>
  
  <pre><code>@Entity
  @Table(name="verbete")
  public class Verbete implements Serializable{
     ...
  
      @ManyToOne
      @JoinColumn(name="catVerb_id", insertable = false, updatable = false)
      public CategoriaVerbete getCategoria() {
          return categoria;
      }
      public void setCategoria(CategoriaVerbete categoria) {
          this.categoria = categoria;
      }
  
      ...
  }
  </code></pre>
  
  <p>SignificadosVerbete</p>
  
  <pre><code>@Entity
  @Table(name="verbete_significados")
  public class SignificadosVerbete {
      ... 
  
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name="catVerb_id", insertable = false, updatable = false)
      public CategoriaVerbete getCategoria() {
          return categoria;
      }
      public void setCategoria(CategoriaVerbete categoria) {
          this.categoria = categoria;
      }
  
     ...
  
  }
  </code></pre>
  
  <p>In the database...</p>
  
  <pre><code>CREATE TABLE verbete_categoria (
  catVerb_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
  catVerb_nome VARCHAR(100) UNIQUE,
  catVerb_descricao MEDIUMTEXT,
  catVerb_serie INT NOT NULL
  );
  </code></pre>
  
  <p>Any help will be appreciated, thank you.</p>
  
  <p><strong>UPDATE - PROBLEM SOLVED</strong></p>
  
  <p>Well, I was expecting a triumphant soundtrack, but it's ok...</p>
  
  <p>I just followed what this link says:</p>
  
  <p><a href="https://www.ibm.com/developerworks/community/blogs/fd26864d-cb41-49cf-b719-d89c6b072893/entry/como_criar_relacionamento_onetomany_com_hibernate?lang=en">https://www.ibm.com/developerworks/community/blogs/fd26864d-cb41-49cf-b719-d89c6b072893/entry/como_criar_relacionamento_onetomany_com_hibernate?lang=en</a> </p>
  
  <p>I read that what is in that link isn't recommended by the Hibernate documentation, but I tried to follow the recomendations and passed one week treating errors. So, I hope this helps other people.</p>
  
  <p>And thanks for all the answers.</p>