title: EntityManager + @Transactional
body: <pre><code>@Service
  @Repository
  @Transactional
  public class VideoService  {
  
      @PersistenceContext
      EntityManager entityManager;
  
      public void save(Video video) {
  
          Video video1 = new Video();
  
          entityManager.persist(video1);
  
      }
  
  
  
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt;
      &lt;persistence-unit name="video_pu" transaction-type="RESOURCE_LOCAL" &gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  
          &lt;properties&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="create-drop" /&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt;
          &lt;/properties&gt;
  
      &lt;/persistence-unit&gt;
  &lt;/persistence&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/video" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="root" /&gt;
      &lt;/bean&gt;     
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
        &lt;property name="persistenceUnitName" value="video_pu"/&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;      
        &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
             &lt;property name="showSql" value="true" /&gt;
             &lt;property name="generateDdl" value="true" /&gt;
             &lt;property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /&gt;
          &lt;/bean&gt;
       &lt;/property&gt;
  
      &lt;/bean&gt;
  
  
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
         &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- enable the configuration of transactional behavior based on annotations --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  
  
      &lt;!-- post-processors for all standard config annotations --&gt;
      &lt;context:annotation-config/&gt;
  </code></pre>
  
  <p>The transaction in service method save(Video video) is never started so also never commited. Where is the error? When I use EntityManagerFactory it works perfectly, but I don't want to explicitly begin and commit transaction. I want to use it with @Transactional annotation.</p>