title: How Can I insert some data while using JTA Entity Manager
body: <p>I'm using JBoss 7.1 AS in my application , JPA, Hibernate and MySql DB, I configured everything well and my program is fetching data from db normal. The problem is when I try to insert some data . I found out is the normal that JTA EntityManager cannot use get Transaction , so my question is how Can i insert some data to my db ?  Have no idea how Spring works so don't point me to that please, unless it's simple.  </p>
  
  <p>my persistance looks like that now:</p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/persistence                    
           http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
           version="2.0"&gt;
    &lt;persistence-unit name="EngineProject" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
  
  
          &lt;jta-data-source&gt;java:jboss/datasources/MySqlDS&lt;/jta-data-source&gt;
          &lt;class&gt;org.itdevelopment.DAO.User&lt;/class&gt;
  
  
      &lt;properties&gt;
  
        &lt;property name="hibernate.show.sql" value="true" /&gt;
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="create" /&gt;
      &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  </code></pre>
  
  <p> </p>
  
  <p>and my what im trying to do is simple insert some data in the ManagedBean, User class , a a method:</p>
  
  <pre><code>      em.getTransaction().begin();
  
          User employee = new User();
          employee.setId(23);
          employee.setCompany("Coca cola");;
          employee.setLogin("James");
  
          em.persist(employee);
          em.getTransaction().commit();
  </code></pre>
  
  <p>as I said it returns:
        A JTA EntityManager cannot use getTransaction()
      So how Can I insert something ?</p>
  
  <p>Thank you.
  M</p>