Guest User

Untitled

a guest
Dec 15th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Unable to build Hibernate SessionFactory
  2.  
  3. @EnableTransactionManagement
  4. public class JPAConfiguration {
  5.  
  6. @Bean
  7. public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  8. LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
  9. JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
  10. emf.setJpaVendorAdapter(jpaVendorAdapter );
  11.  
  12. DriverManagerDataSource dataSource = new DriverManagerDataSource();
  13. dataSource.setUsername("root");
  14. dataSource.setPassword("123123");
  15. dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/sistema-web-05");
  16. dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  17.  
  18. Properties properties = new Properties();
  19. properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
  20. properties.setProperty("hibernate.show_sql", "true");
  21. properties.setProperty("hibernate.hbm2ddl.auto", "update");
  22. emf.setJpaProperties(properties);
  23. emf.setPackagesToScan("sistema.estoque.springmvc.model");
  24. return emf;
  25. }
  26.  
  27. @Bean
  28. public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
  29. return new JpaTransactionManager(emf);
  30. }
  31. }
Add Comment
Please, Sign In to add comment