title: how to save data with save method of jpa Repository
body: <p>While adding the entity from service implemented class to Repository interface , it showing successful message but data does not inserted to the database i call the save(entity) method from JpaRepository interface . it does not show any error message instead of that it showing record inserted successfully message .    </p>
  
  <p>Controller --- >>.</p>
  
  <pre><code>@Controller
  @RequestMapping("/cart")
  public class CartController {
  
      @Autowired
      CartService cartServices;
  
      /**
       * Get All records in Cart
       *  
       * @return All Cart List
       */
      @RequestMapping(value = "/list", method = RequestMethod.GET)
      public @ResponseBody List&lt;Cart&gt; getCart() {
  
          List&lt;Cart&gt; cartList = null;
          try {
              cartList = cartServices.getCartList();
  if(cartList.isEmpty())
  {
      System.out.println("List is empty ");
  }
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          return cartList;
      }
      /**
       * Add Cart
       * 
       * @param representative
       * @return Status
       */
      @RequestMapping(value = "/create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
      public @ResponseBody Status addCart(@RequestBody Cart cart) {
          System.out.println("i m from jpa controller");
          try {
              cartServices.save(cart);
              return new Status(1, "Cart added Successfully !");
          } catch (Exception e) {
              // e.printStackTrace();
              return new Status(0, e.toString());
          }
  
      }
  </code></pre>
  
  <p>Service Implemented class------>>>></p>
  
  <pre><code>@Service
  public class CartServiceImpl implements CartService {
  
  
      @Inject
      CartRepository cartRepository;
  
  
      /**
       * Get All Cart
       * 
       * @throws Exception
       * @return All Cart List
       */
  
      @Override
      @Transactional
      public List&lt;Cart&gt; getCartList() throws Exception {
          // TODO Auto-generated method stub
          return cartRepository.findAll();
      }
  
      /**
       * Add Cart
       * 
       * @param cart
       * @throws Exception
       * @return Boolean
       */
      @Override
      @Transactional
      public Cart save(Cart cart) throws Exception {
          System.out.println("i m from jpa Service");
  
  
          Cart cart1 = cartRepository.save(cart);
          return    cart1;
      }
  </code></pre>
  
  <p>Repository Interface-------->>>></p>
  
  <pre><code>package com.xptraining.repository;
  
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  import com.xptraining.model.Cart;
  
  
  @Repository
  public interface CartRepository extends JpaRepository&lt;Cart, Long&gt;
  {
  
  
  }
  </code></pre>
  
  <p>Web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;xptraining&lt;/display-name&gt;
    &lt;servlet&gt;
    &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
     &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
     &lt;param-value&gt;/WEB-INF/rest.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
   &lt;/servlet&gt;
  
   &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>rest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd  
    http://www.springframework.org/schema/data/jpa 
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&gt;
  
   &lt;context:component-scan base-package="com.xptraining" /&gt;
    &lt;jpa:repositories base-package="com.xptraining.repository"
                    entity-manager-factory-ref="entityManagerFactoryBean"
                    transaction-manager-ref="txManager"/&gt;
   &lt;!--  &lt;jpa:repositories base-package="com.xptraining.repository"&gt;&lt;/jpa:repositories&gt; --&gt;
  &lt;!-- &lt;jpa:repositories base-package="com.xptraining.repository"
                    entity-manager-factory-ref="cartRepository"
                    transaction-manager-ref="transactionManager"/&gt;  --&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
  &lt;bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
        &lt;!-- This makes /META-INF/persistence.xml is no longer necessary --&gt;
        &lt;property name="packagesToScan" value="com.xptraining.model" /&gt;
        &lt;!-- JpaVendorAdapter implementation for Hibernate EntityManager.
             Exposes Hibernate's persistence provider and EntityManager extension interface --&gt;
        &lt;property name="jpaVendorAdapter"&gt;
           &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
        &lt;/property&gt;
        &lt;property name="jpaProperties"&gt;
           &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
           &lt;/props&gt;
        &lt;/property&gt;
     &lt;/bean&gt;
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/training" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="xpointers" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.xptraining.model.Product&lt;/value&gt;
                  &lt;value&gt;com.xptraining.model.Specialties&lt;/value&gt;
                  &lt;value&gt;com.xptraining.model.Representative&lt;/value&gt;
                  &lt;value&gt;com.xptraining.model.Cart&lt;/value&gt;
                  &lt;value&gt;com.xptraining.model.Sku&lt;/value&gt;
                  &lt;value&gt;com.xptraining.model.Order&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.MySQL5Dialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="txManager"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="persistenceExceptionTranslationPostProcessor"
          class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
  
      &lt;bean id="dataDao" class="com.xptraining.dal.impl.DataDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="dataServices" class="com.xptraining.services.impl.DataServicesImpl"&gt;&lt;/bean&gt;
      &lt;bean id="specialtiesDao" class="com.xptraining.dal.impl.SpecialtiesDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="specialtiesServices" class="com.xptraining.services.impl.SpecialtiesServicesImpl"&gt;&lt;/bean&gt;
      &lt;bean id="representativeDao" class="com.xptraining.dal.impl.RepresentativeDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="representativeService" class="com.xptraining.services.impl.RepresentativeServiceImpl"&gt;&lt;/bean&gt;
      &lt;bean id="skuDao" class="com.xptraining.dal.impl.SkuDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="skuServices" class="com.xptraining.services.impl.SkuervicesImpl"&gt;&lt;/bean&gt;
      &lt;bean id="cartDao" class="com.xptraining.dal.impl.CartDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="cartServices" class="com.xptraining.services.impl.CartServiceImpl"&gt;&lt;/bean&gt;
      &lt;bean id="orderDao" class="com.xptraining.dal.impl.OrderDaoImpl"&gt;&lt;/bean&gt;
      &lt;bean id="orderServices" class="com.xptraining.services.impl.OrderServicesImpl"&gt;&lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>@My console when i call save method</p>
  
  <pre><code>10:48:55.219 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'mvc-dispatcher' processing POST request for [/xptraining/cart/create]
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /cart/create
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Returning handler method [public com.xptraining.model.Status com.xptraining.controller.CartController.addCart(com.xptraining.model.Cart)]
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'cartController'
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor - Read [class com.xptraining.model.Cart] as "application/json" with [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@48e069ed]
  i m from jpa controller
  i m from jpa Service
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Opened new Session [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=org.hibernate.engine.spi.ExecutableList@23b8bcb1 updates=org.hibernate.engine.spi.ExecutableList@2d7f56b6 deletions=org.hibernate.engine.spi.ExecutableList@2940d7c1 orphanRemovals=org.hibernate.engine.spi.ExecutableList@6c425c8d collectionCreations=org.hibernate.engine.spi.ExecutableList@a793880 collectionRemovals=org.hibernate.engine.spi.ExecutableList@5d64159f collectionUpdates=org.hibernate.engine.spi.ExecutableList@72b52f2d collectionQueuedOps=org.hibernate.engine.spi.ExecutableList@c6da3c2 unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])] for Hibernate transaction
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Preparing JDBC Connection of Hibernate Session [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=org.hibernate.engine.spi.ExecutableList@23b8bcb1 updates=org.hibernate.engine.spi.ExecutableList@2d7f56b6 deletions=org.hibernate.engine.spi.ExecutableList@2940d7c1 orphanRemovals=org.hibernate.engine.spi.ExecutableList@6c425c8d collectionCreations=org.hibernate.engine.spi.ExecutableList@a793880 collectionRemovals=org.hibernate.engine.spi.ExecutableList@5d64159f collectionUpdates=org.hibernate.engine.spi.ExecutableList@72b52f2d collectionQueuedOps=org.hibernate.engine.spi.ExecutableList@c6da3c2 unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])]
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtaining JDBC connection
  10:48:55.220 [http-nio-8080-exec-10] DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/training]
  10:48:55.223 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtained JDBC connection
  10:48:55.223 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.spi.AbstractTransactionImpl - begin
  10:48:55.223 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction - initial autocommit status: true
  10:48:55.223 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction - disabling autocommit
  10:48:55.223 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [com.mysql.jdbc.JDBC4Connection@5c26bcfd]
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Opening JPA EntityManager
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Registering transaction synchronization for JPA EntityManager
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.hibernate.loader.Loader - Loading entity: [com.xptraining.model.Cart#1]
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.hibernate.SQL - select cart0_.cart_id as cart_id1_0_0_, cart0_.prize as prize2_0_0_, cart0_.quantity as quantity3_0_0_, cart0_.representative_id as represen4_0_0_, cart0_.sku_id as sku_id5_0_0_ from cart cart0_ where cart0_.cart_id=?
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtaining JDBC connection
  10:48:55.224 [http-nio-8080-exec-10] DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/training]
  10:48:55.226 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Obtained JDBC connection
  10:48:55.226 [http-nio-8080-exec-10] DEBUG org.hibernate.loader.Loader - Result set row: 0
  10:48:55.226 [http-nio-8080-exec-10] DEBUG org.hibernate.loader.Loader - Result row: EntityKey[com.xptraining.model.Cart#1]
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Resolving associations for [com.xptraining.model.Cart#1]
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.internal.TwoPhaseLoad - Done materializing entity [com.xptraining.model.Cart#1]
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.loader.Loader - Done entity load
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Releasing JDBC connection
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Released JDBC connection
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Initiating transaction commit
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Committing Hibernate transaction on Session [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=org.hibernate.engine.spi.ExecutableList@23b8bcb1 updates=org.hibernate.engine.spi.ExecutableList@2d7f56b6 deletions=org.hibernate.engine.spi.ExecutableList@2940d7c1 orphanRemovals=org.hibernate.engine.spi.ExecutableList@6c425c8d collectionCreations=org.hibernate.engine.spi.ExecutableList@a793880 collectionRemovals=org.hibernate.engine.spi.ExecutableList@5d64159f collectionUpdates=org.hibernate.engine.spi.ExecutableList@72b52f2d collectionQueuedOps=org.hibernate.engine.spi.ExecutableList@c6da3c2 unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])]
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.spi.AbstractTransactionImpl - committing
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction - committed JDBC Connection
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction - re-enabling autocommit
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.springframework.orm.hibernate4.HibernateTransactionManager - Closing Hibernate Session [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=org.hibernate.engine.spi.ExecutableList@23b8bcb1 updates=org.hibernate.engine.spi.ExecutableList@2d7f56b6 deletions=org.hibernate.engine.spi.ExecutableList@2940d7c1 orphanRemovals=org.hibernate.engine.spi.ExecutableList@6c425c8d collectionCreations=org.hibernate.engine.spi.ExecutableList@a793880 collectionRemovals=org.hibernate.engine.spi.ExecutableList@5d64159f collectionUpdates=org.hibernate.engine.spi.ExecutableList@72b52f2d collectionQueuedOps=org.hibernate.engine.spi.ExecutableList@c6da3c2 unresolvedInsertDependencies=UnresolvedEntityInsertActions[]])] after transaction
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Releasing JDBC connection
  10:48:55.227 [http-nio-8080-exec-10] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl - Released JDBC connection
  10:48:55.228 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor - Written [com.xptraining.model.Status@788e053b] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@48e069ed]
  10:48:55.228 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling
  10:48:55.228 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
  </code></pre>