Quando rodo o projeto, ele vem normalmente com 3 conexões (Aba estatísticas), porém assim que clico em home, vou olhar em estatísticas e está 4, e toda vez que clico em home aumenta.
Classe JPA Configurator
@Bean(destroyMethod = "close")
public DataSource getDataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass("com.mysql.jdbc.Driver");
dataSource.setJdbcUrl("jdbc:mysql://localhost/projeto_jpa");
dataSource.setUser("root");
dataSource.setPassword("password");
dataSource.setMinPoolSize(3);//numero mínimo de conexões
dataSource.setMaxPoolSize(5);//numero máximo de conexões
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean getEntityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setPackagesToScan("br.com.caelum");
entityManagerFactory.setDataSource(dataSource);
entityManagerFactory
.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
Properties props = new Properties();
props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
props.setProperty("hibernate.show_sql", "true");
props.setProperty("hibernate.hbm2ddl.auto", "create-drop");
props.setProperty("hibernate.cache.use_second_level_cache", "true");
props.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory");
props.setProperty("hibernate.cache.use_query_cache", "true");
props.setProperty("hibernate.generate_statistics", "true");
entityManagerFactory.setJpaProperties(props);
return entityManagerFactory;
}