title: Save method not persisting entity object Spring Data JPA
body: <p>I am moving my current code from hibernate and mybatis to spring data jpa.I configured spring data with my existing application and tried to perform certain operations.</p>
  
  <p>When I tried to persist an entity using save(T t) it didn't return any exception and returned same entity object as result but didn't persist.</p>
  
  <p>Persistence.xml</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  
  &lt;tx:annotation-driven /&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="com.mysql.jdbc.Driver" p:url="${db.url}"
      p:username="${db.username}" p:password="${db.password}" /&gt;
  
  &lt;!-- Hibernate 4 SessionFactory Bean definition --&gt;
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan"&gt;
          &lt;list&gt;
              &lt;value&gt;com.moneyhaul.dao.model&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;!--&lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;--&gt;
  </code></pre>
  
  
  
  <pre><code>&lt;!--
            Configure Spring Data JPA and set the base package of the
            repository interfaces
          --&gt;
  &lt;jpa:repositories base-package="com.moneyhaul.repositary"/&gt;
  
  
      &lt;!-- Create default configuration for Hibernate --&gt;
      &lt;bean id="hibernateJpaVendorAdapter"
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
  
      &lt;!-- Configure the entity manager factory bean --&gt;
      &lt;bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/&gt;
          &lt;!-- Set JPA properties --&gt;
          &lt;property name="jpaProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/prop&gt;
                  &lt;prop key="javax.persistence.schema-generation.database.action"&gt;none&lt;/prop&gt;
                  &lt;prop key="hibernate.ejb.use_class_enhancer"&gt;false&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
          &lt;!-- Set base package of your entities --&gt;
          &lt;property name="packagesToScan" value="com.moneyhaul.dao.model"/&gt;
          &lt;!-- Set share cache mode --&gt;
          &lt;property name="sharedCacheMode" value="ENABLE_SELECTIVE"/&gt;
          &lt;!-- Set validation mode --&gt;
          &lt;property name="validationMode" value="NONE"/&gt;
  
      &lt;/bean&gt;
  
      &lt;!-- Configure the transaction manager bean --&gt;
      &lt;bean id="transactionManagerJpa"
            class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- Enable annotation driven transaction management --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManagerJpa"/&gt;
  
  
  
  
  
  
  
  
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Mybatis session factory --&gt;
  &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
      p:dataSource-ref="dataSource" p:configLocation="WEB-INF/mybatis/sqlmap-config.xml" /&gt;
  
  &lt;bean id="caarmoMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.CaarmoMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="paymentMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.PaymentMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="reportingMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.ReportingMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="reportingTrendsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.ReportingTrendsMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="customerDBMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.CustomerDBMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="vehicleDBMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.VehicleDBMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="geomaticsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.GeomaticsMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="serviceCenterMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.ServiceCenterMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="moneyhaulMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.moneyhaul.mapper.MoneyHaulMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="mhGeomaticsMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.moneyhaul.mapper.MHGeomaticsMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  
  &lt;bean id="configurationMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"
      p:mapperInterface="com.caarmo.mapper.ConfigurationMapper"
      p:sqlSessionFactory-ref="sqlSessionFactory" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>DriverRepositary.java</p>
  
  <pre><code>@Repository
  public interface DriverRepositary extends CrudRepository&lt;Driver,Long&gt;{}
  </code></pre>
  
  <p>Persisting entity </p>
  
  <pre><code>@Transactional
  public void addDriver(Driver driver) {
      driver.setTabletPassword(setDriverPassword(driver.getPhone()));
      driver.setUpdated(new Date());
      driverRepositary.save(driver);
  
  }
  </code></pre>