Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EnableTransactionManagement
- public class JPAConfig {
- @Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
- LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean =
- new LocalContainerEntityManagerFactoryBean();
- JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
- localContainerEntityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
- DriverManagerDataSource driverManagerDataSource =
- new DriverManagerDataSource();
- driverManagerDataSource.setUsername("root");
- driverManagerDataSource.setPassword("");
- driverManagerDataSource.setUrl("jdbc:mysql://localhost:3306/odontology");
- driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
- localContainerEntityManagerFactoryBean.setDataSource(driverManagerDataSource);
- Properties properties = new Properties();
- properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
- properties.setProperty("hibernate.show_sql", "true");
- properties.setProperty("hibernate.hbm2ddl.auto", "update");
- localContainerEntityManagerFactoryBean.setJpaProperties(properties);
- localContainerEntityManagerFactoryBean.setPackagesToScan("org.odontology.models");
- return localContainerEntityManagerFactoryBean;
- }
- @Bean
- public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory){
- return new JpaTransactionManager(entityManagerFactory);
- }
- }
- org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement