title: org.hibernate.internal.ExceptionConverterImpl.convertCommitException (JPA, No Spring)
body: <p>I have a problem when trying to add a <code>Real_State</code> value to Mysql BD, but I cant figure out what's wrong with it, I am a newbie at this JPA so I don't have a near clue about what am I doing wrong, but i'd be glad to learn it:</p>
  <pre class="lang-java prettyprint-override"><code>    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              String address = request.getParameter(&quot;address&quot;);
              String block  = request.getParameter(&quot;block&quot;);
              int internal_id = Integer.parseInt(request.getParameter(&quot;internal_id&quot;));
              String RealStateEnum = request.getParameter(&quot;RealStateEnum&quot;);
              RealState realState = new RealState();
              RealStateID realStateID = new RealStateID(address, block, internal_id);
              realState.setRealStateEnum(edu.uptc.entity.RealStateEnum.APARTMENT);
              realState.setRealStateID(realStateID);
              Admin admin = new Admin();
              admin.setAdmin_id(&quot;1&quot;);
              admin.setAdmin_name(&quot;pepe&quot;);
              admin.setAdmin_phone(&quot;32132&quot;);
              List&lt;RealState&gt; realStates = new ArrayList&lt;RealState&gt;();
              realStates.add(realState);
              admin.setRealStates(realStates);
              realState.setAdmin(admin);
              manager m = new manager();
              boolean res=false;
              res = m.addState(realState);
      }
  </code></pre>
  <p>and doPost method is calling the next:</p>
  <pre class="lang-java prettyprint-override"><code>    public boolean addState(RealState realState) {
          boolean res = false;
          em.getTransaction().begin();
          em.persist(realState);
          em.getTransaction().commit(); //this is the ERROR trigger line
          res=true;
          return res;
      }
  </code></pre>
  <pre><code>And the implied Entities in the transaction are: 
  </code></pre>
  <p>RealStates:</p>
  <pre class="lang-java prettyprint-override"><code>    @Entity
      @Table(name = &quot;real_states&quot;)
      public class RealState implements Serializable{
          private static final long serialVersionUID = 4033627448194380926L;
          @EmbeddedId
          private RealStateID realStateID;
          @Column(name = &quot;real_state_type_id&quot;)
          @Enumerated(EnumType.ORDINAL)
          private RealStateEnum realStateEnum;
          @ManyToOne(cascade = CascadeType.ALL)
          private Admin admin;
          //getters &amp; setters...
  }
  </code></pre>
  <p>Admin:</p>
  <pre class="lang-java prettyprint-override"><code>    @Entity
      @Table(name = &quot;admins&quot;)
      public class Admin implements Serializable{
          private static final long serialVersionUID = 6412538388289111906L;
          @Id
          @Column(name = &quot;admin_id&quot;)
          private String admin_id;
          @Column(name = &quot;admin_name&quot;)
          private String admin_name;
          @Column(name = &quot;admin_phone&quot;)
          private String admin_phone;
          @OneToMany(mappedBy = &quot;admin&quot;, cascade = CascadeType.ALL)
          private List&lt;RealState&gt; realStates;
          //getters &amp; setters...
      }
  </code></pre>
  <p>And the exception i am  getting is :</p>
  <pre><code>    javax.persistence.RollbackException: Error while committing the transaction
          at org.hibernate@5.3.20.Final//org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:81)
          at org.hibernate@5.3.20.Final//org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:107)
          at deployment.ProyectoSw.war//edu.uptc.model.manager.addState(manager.java:47)
          at deployment.ProyectoSw.war//edu.uptc.control.AddStateServlet.doPost(AddStateServlet.java:65)
          at javax.servlet.api@2.0.0.Final//javax.servlet.http.HttpServlet.service(HttpServlet.java:523)
          at javax.servlet.api@2.0.0.Final//javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
          at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
          at ...
  </code></pre>
  <p>Edit:</p>
  <pre><code>    Caused by: java.sql.SQLException: Field 'admin_id' doesn't have a default value
  </code></pre>
  <p>That's the cause eclipse ID points to. But I am clearly setting admin_id to &quot;1&quot;</p>