Java 类org.hibernate.hikaricp.internal.HikariCPConnectionProvider 实例源码

项目:Plume    文件:HibernateFactory.java   
/**
 * Extrait une DataSource d'une EntityManagerFactory
 */
public static DataSource applicationDataSource(EntityManagerFactory entityManagerFactory) {
    EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManagerFactory.createEntityManager();
    try {
        HikariCPConnectionProvider hikariCPConnectionProvider = (HikariCPConnectionProvider) entityManagerImpl.getFactory().getSessionFactory().getServiceRegistry().getService(ConnectionProvider.class);

        Field dataSourceField = HikariCPConnectionProvider.class.getDeclaredField("hds");
        dataSourceField.setAccessible(true);
        return (HikariDataSource) dataSourceField.get(hikariCPConnectionProvider);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new RuntimeException(e);
    } finally {
        entityManagerImpl.close();
    }
}
项目:high-performance-java-persistence    文件:HikariCPCockroachDBConnectionProviderTest.java   
@Override
protected void appendDriverProperties(Properties properties) {
    DataSourceProvider dataSourceProvider = dataSourceProvider();
    properties.put("hibernate.connection.provider_class", HikariCPConnectionProvider.class.getName());
    properties.put("hibernate.hikari.minimumPoolSize", "1");
    properties.put("hibernate.hikari.maximumPoolSize", "2");
    properties.put("hibernate.hikari.transactionIsolation", "TRANSACTION_SERIALIZABLE");
    properties.put("hibernate.hikari.dataSourceClassName", dataSourceProvider.dataSourceClassName().getName());
    properties.put("hibernate.hikari.dataSource.url", dataSourceProvider.url());
    properties.put("hibernate.hikari.dataSource.user", dataSourceProvider.username());
    properties.put("hibernate.hikari.dataSource.password", dataSourceProvider.password());
}
项目:high-performance-java-persistence    文件:HikariCPConnectionProviderTest.java   
@Override
protected void appendDriverProperties(Properties properties) {
    DataSourceProvider dataSourceProvider = dataSourceProvider();
    properties.put("hibernate.connection.provider_class", HikariCPConnectionProvider.class.getName());
    properties.put("hibernate.hikari.maximumPoolSize", "5");
    properties.put("hibernate.hikari.dataSourceClassName", dataSourceProvider.dataSourceClassName().getName());
    properties.put("hibernate.hikari.dataSource.url", dataSourceProvider.url());
    properties.put("hibernate.hikari.dataSource.user", dataSourceProvider.username());
    properties.put("hibernate.hikari.dataSource.password", dataSourceProvider.password());
}