title: Spring Data CRUD Repository: save method does not work
body: <p><strong>This is not about Spring Boot at all.</strong></p>
  <p><em>My English could be better.</em></p>
  <p>Using below Config for Spring Data I'm trying to execute DML requests.</p>
  <p>Exactly <code>CrudRepository#save</code> method.</p>
  <p>However executing Spring's CrudRepository#save method I'm getting next:</p>
  <ol>
  <li>ONLY Selects are logged by <code>hibernate.show_sql</code> feature.</li>
  <li>No &quot;insert&quot; or &quot;update&quot; statements are being executed as to hibernate.show_sql logging.</li>
  <li>No changes at database at all.</li>
  </ol>
  <p>====================================================</p>
  <p>Not sure but it looks like a Transaction issue.</p>
  <p>Seems that there is no transaction at that point,</p>
  <p>so out of transaction CRUD Repos is not able to execute DML requests,
  including <code>CrudRepository#save</code>.</p>
  <p>Maybe it is something wrong with configuration?
  Have a look please and feel free to ask for any additional info.</p>
  <p><strong>UPDATE:</strong>
  The next bad-practice workaround helped me to reach the &quot;Update&quot; statements execution.</p>
  <pre><code>//(autowired, shared entity manager)
  entityManager.joinTransaction();
  repository.save(user);
  </code></pre>
  <p>However it is still a bad practice approach. In this case Spring's purpose is lost.
  Anyway it is required for me to use Declarative Code-based Transaction managment.
  Question is still open:
  <strong>What is wrong with my config? @Transactional annotation still doesn't work</strong></p>
  <p>User domain entity:</p>
  <pre><code>@Data
  @EqualsAndHashCode(callSuper = true)
  @NoArgsConstructor
  @Entity
  @Table(name = &quot;users&quot;)
  public class User
  {
      @Id
      @Column(name = &quot;id_pk&quot;, length = 11)
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int idPk;
  
      @Column(name = &quot;user_id&quot;, length = 25, nullable = false, unique = true)
      private String userId;
  
      @Column(name = &quot;email_addr&quot;, length = 120)
      private String email;
  }
  </code></pre>
  <p>Domain-specific Spring Data CRUD Repository declaration:</p>
  <pre><code>public interface UserRepository extends CrudRepository&lt;User, Integer&gt; {
    //nothing specific
  }
  </code></pre>
  <p>Spring <strong>(Boot-less)</strong> Code-based configuration:</p>
  <pre><code>@EnableJpaRepositories(basePackages = &quot;***&quot;,
          transactionManagerRef = &quot;jpaTransactionManager&quot;)
  @EnableTransactionManagement
  public class DataConfig
  {
      @Bean
      public EntityManagerFactory entityManagerFactory()
      {
          LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
          factory.setDataSource(dataSource());
          factory.setPackagesToScan(DOMAIN_ENTITY_SCAN_PACKAGE);
          factory.setJpaVendorAdapter(getVendorAdapter());
          factory.afterPropertiesSet();
          return factory.getObject();
      }
  
      private HibernateJpaVendorAdapter getVendorAdapter()
      {
          HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
          vendorAdapter.setShowSql(Boolean.TRUE);
          return vendorAdapter;
      }
  
      @Bean
      public JpaTransactionManager jpaTransactionManager()
      {
          JpaTransactionManager txManager = new JpaTransactionManager();
          txManager.setEntityManagerFactory(entityManagerFactory());
          txManager.afterPropertiesSet();
          return txManager;
      }
  }
  </code></pre>