title: JTATransactionManager Not Committing To Database
body: <p>I will be working with a database and with a JMS queue so I decided to use JTATransactionManager (multiple resources).<br/>
  I am using Spring Framework 3.2.3.RELEASE<br/>
  Hibernate 4.2.1.Final<br/>
  Glassfish 3.1.2.2<br/></p>
  
  <p>With JTATransactionManager nothing is committed to db.I tried JPATransactionManager it works fine.I don't get any exceptions with JTATransactionManager.Any idea what I am doing wrong?Thanks.</p>
  
  <p>This is a piece of jpa config file</p>
  
  <pre><code>&lt;jee:jndi-lookup id="dataSource" jndi-name="Test" /&gt;
  
  &lt;bean id="entityManagerFactory"
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
         p:packagesToScan="com.pinkshield.jpaTest.domain" 
         p:dataSource-ref="dataSource"
         p:jpaPropertyMap-ref="jpaPropertyMap" 
         p:jpaVendorAdapter-ref="hibernateVendor" /&gt;
  
  
  &lt;util:map id="jpaPropertyMap"&gt;
      &lt;entry key="hibernate.hbm2ddl.auto" value="validate" /&gt;
      &lt;entry key="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" /&gt;
      &lt;entry key="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" /&gt;
      &lt;entry key="transaction.manager_lookup_class"
          value="org.hibernate.transaction.SunONETransactionManagerLookup" /&gt;
  &lt;/util:map&gt;
  
  &lt;bean id="hibernateVendor"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
      p:showSql="true" /&gt;
  
  &lt;tx:jta-transaction-manager /&gt;
  
  &lt;context:component-scan base-package="com.pinkshield.jpaTest" /&gt;
  </code></pre>
  
  <p>This is my Generic Dao for JPA</p>
  
  <pre><code>package com.pinkshield.jpaTest;
  
  import java.util.List;
  
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  
  public class GenericDaoJpa&lt;T&gt; implements GenericDao&lt;T&gt; 
  {
  
  private Class&lt;T&gt; queryClass;
  protected EntityManager entityManager;
  
  @PersistenceContext
  public void setEntityManager(EntityManager entityManager) 
  {
      this.entityManager = entityManager;
  }   
  
  public GenericDaoJpa(Class&lt;T&gt; queryClass) 
  {
      super();
      this.queryClass = queryClass;
  }
  
  public T getNewInstance() 
  {
      try 
      {
          return getQueryClass().newInstance();
      } 
      catch (InstantiationException e) 
      {
          throw new RuntimeException("Error creating new instance of : " + getQueryClass().getName(), e);
      } 
      catch (IllegalAccessException e) 
      {
          throw new RuntimeException("Error creating new instance of : " + getQueryClass().getName(), e);
      }
  }
  
  public Class&lt;T&gt; getQueryClass() 
  {
      return queryClass;
  }    
  
  public T get(Long id) 
  {
      if (id == null) 
      {
          return null;
      } 
      else 
      {
          return entityManager.find(queryClass, id);
      }
  }
  
  @SuppressWarnings("unchecked")
  public List&lt;T&gt; getAll() 
  {
      return entityManager.createQuery("select o from " + queryClass.getName() + " o").getResultList();
  }
  
  public void save(T object) 
  {
      entityManager.persist(object);
  }
  
  public void update(T object) 
  {
      entityManager.merge(object);
  }
  
  public void delete(T object) 
  {
      entityManager.remove(entityManager.merge(object));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is UserDao</p>
  
  <pre><code>@Repository
  public class UserDao extends GenericDaoJpa&lt;User&gt; 
  {
  public UserDao() 
  {
      super(User.class);
  }
  }
  </code></pre>
  
  <p>And this is my service code</p>
  
  <pre><code> @Service
   public class UserServiceImpl implements IUserService{
  
  @Autowired UserDao userDao;
  
  @Override
  @Transactional
  public void saveUser(String name, String lastName)
    { 
      User user=new User();
      user.setLastName(lastName);
      user.setName(name);
  
      userDao.save(user);
     }
   }
  </code></pre>