content: package com.adamzareba.spring.security.oauth2.config;
  
  import com.fasterxml.jackson.databind.Module;
  import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
  import org.springframework.orm.jpa.JpaTransactionManager;
  import org.springframework.transaction.PlatformTransactionManager;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  
  import javax.persistence.EntityManagerFactory;
  
  @Configuration
  @EnableTransactionManagement
  public class HibernateConfiguration {
  
      @Bean
      public Module hibernate5Module() {
          return new Hibernate5Module();
      }
  
      @Bean
      public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
          JpaTransactionManager transactionManager = new JpaTransactionManager();
          transactionManager.setEntityManagerFactory(emf);
  
          return transactionManager;
      }
  
      @Bean
      public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
          return new PersistenceExceptionTranslationPostProcessor();
      }
  }
  