@Override public void initialize() { // Set sessionTransacted=true in case of a non-JTA transaction manager. if (!this.sessionTransactedCalled && this.transactionManager instanceof ResourceTransactionManager && !TransactionSynchronizationUtils.sameResourceFactory( (ResourceTransactionManager) this.transactionManager, getConnectionFactory())) { super.setSessionTransacted(true); } // Use bean name as default transaction name. if (this.transactionDefinition.getName() == null) { this.transactionDefinition.setName(getBeanName()); } // Proceed with superclass initialization. super.initialize(); }
@Bean @Autowired public ResourceTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { return new JpaTransactionManager(entityManagerFactory); }