title: JPA .persist() doesn't save the data to the database while read works properly
body: <p>I have a Spring/JPA (with Hibernate as the JPA provider) with MySQL as the database provider.
  I can't seem to be able to persist the data successfully even though I can read the data from the database.</p>
  
  <p>I have searched through stackoverflow and most of the solutions dealt with decorating the save method with @Transactional (also the class). I verified the overall configuration but I can't seem to find out where I'm going wrong.</p>
  
  <p>Here is my configuration</p>
  
  <p>persistence.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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/ p   ersistence/persistence_2_0.xsd"
               version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt;
      &lt;persistence-unit name="brPersistenceUnit" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;jta-data-source&gt;java:comp/env/jdbc/brDS&lt;/jta-data-source&gt;
          &lt;class&gt;com.uhsarp.br.domain.Bill&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="validate"/&gt;
                &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt; 
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>spring application context</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
     &lt;beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context-3.0.xsd
                            http://www.springframework.org/schema/tx
                            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  
     &lt;!-- JPA Entity Manager Factory --&gt;
   &lt;!--    &lt;bean id="entityManagerFactory" 
           class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
           p:dataSource-ref="brDS"/&gt;--&gt;
  
           &lt;bean id="entityManagerFactory" 
   class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt; 
       &lt;property name="persistenceUnitName" value="brPersistenceUnit"/&gt; 
    &lt;/bean&gt; 
     &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;
  
     &lt;!-- Database LOB Handling --&gt;
     &lt;bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" /&gt;
  
     &lt;!-- Read in DAOs from the JPA package --&gt;
     &lt;context:component-scan base-package="com.uhsarp.br.dao.framework.impl" /&gt;
  
     &lt;!-- Transaction Config --&gt;
     &lt;bean id="transactionManager"
           class="org.springframework.orm.jpa.JpaTransactionManager"
           p:entityManagerFactory-ref="entityManagerFactory"/&gt;
   &lt;tx:annotation-driven/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>snippet of the DAO class</p>
  
  <pre><code> @Repository("billDAO")
   @Transactional
   public class BillDAOImpl  implements BillDAO{
    @PersistenceContext
    private EntityManager em;
  
      @Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
   public Bill save(Bill bill) {
       if (bill.getId() == null) {
                       em.persist(bill);
  
          return bill;
      } else {
          return em.merge(bill);
      }
   }
    }
  </code></pre>