title: EntityManager.persist() not inserting values to DB
body: <p>im new to JPA and Servlets. I'm trying to create Student Entity and insert that to my DB using a Servlet. there are no errors in the code. When I go to the Servlet, it worked without errors in the Browser. But the values are not inserted to my DB.</p>
  
  <p>Student Entity:-</p>
  
  <pre><code>@Entity
  public class Student implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  @Column(nullable = false)
  private String name;
  
  @Column(nullable = false)
  private int age;
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public int getAge() {
      return age;
  }
  
  public void setAge(int age) {
      this.age = age;
  }
  
  
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  
  @Override
  public int hashCode() {
      int hash = 0;
      hash += (id != null ? id.hashCode() : 0);
      return hash;
  }
  
  @Override
  public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Student)) {
          return false;
      }
      Student other = (Student) object;
      if ((this.id == null &amp;&amp; other.id != null) || (this.id != null &amp;&amp; !this.id.equals(other.id))) {
          return false;
      }
      return true;
  }
  
  @Override
  public String toString() {
      return "model.Student[ id=" + id + " ]";
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my Servlet:-</p>
  
  <pre><code>public class A extends HttpServlet {
  
  @PersistenceUnit(unitName = "persistenceCheckPU")
  EntityManagerFactory emf;
  
  @Resource
  UserTransaction ut;
  
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
      try (PrintWriter out = response.getWriter()) {
  
          Student student = new Student();
          student.setName("John");
          student.setAge(22);
  
          EntityManager em = emf.createEntityManager();
          ut.begin();
  
          em.persist(student);
          ut.commit();
  
          out.println("&lt;h2&gt;Success!!!&lt;/h2&gt;");
  
      } catch (SecurityException | IllegalStateException | javax.transaction.RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException | NotSupportedException ex) {
          Logger.getLogger(A.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
  </code></pre>
  
  <p>my Objective:-</p>
  
  <ul>
  <li>Create id as unique and auto increment.</li>
  </ul>
  
  <p><strong>UPDATED</strong></p>
  
  <p>persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"&gt;
  &lt;persistence-unit name="persistenceCheckPU" transaction-type="JTA"&gt;
  &lt;jta-data-source&gt;jdbc_persistence&lt;/jta-data-source&gt;
  &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
  &lt;properties&gt;
    &lt;property name="javax.persistence.schema-generation.database.action" value="create"/&gt;
  &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>