hibernate-orm
hibernate-orm copied to clipboard
HHH-18685 proposed basic enhancement to allow subclasses to have already initialized the HikariDataSource
…ady initialized the HikariDataSource
Provide HikariCPConnectionProvider ability to use a pre-configured HikariDataSource already initialized by subclasses. Many more details in the Jira.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion. For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-18685
Thanks for your pull request!
This pull request does not follow the contribution rules. Could you have a look?
❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
↳ Offending commits: [6da8f7427de3ff4a3c5f47c5c2191e6f0a5d2dea]
› This message was automatically generated.
Changes made as requested.
Please also squash and rebase the commits.
Hi @beikov , sorry, myself and another very smart guy tried to do this, but we are having issues, can you please give us exact steps.
git rebase -i HEAD~2 error: cannot 'squash' without a previous commit You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'. Or you can abort the rebase with 'git rebase --abort'.
Since HikariDataSource is a DataSource why not just use DatasourceConnectionProviderImpl?
Since
HikariDataSourceis aDataSourcewhy not just useDatasourceConnectionProviderImpl?
Hi @sebersole - we have already bootstrapped HikariCP, Hibernate will next call looking for the ConnectionProvider, and it will bypass our HikariDataSource, already created by us because of our unique configuration, we just need HikariCPConnectionProvider to allow us to provide our HikariDataSource in place of creating another one. If we extended a non-Hikari Hibernate class, wouldn't that prevent us from being wired up into the existing HikariCP pools (that we just created) ?
You are clearly configuring Hibernate ORM in a programmatic fashion since you pass an object HikariDataSource as value somehow. Instead of changing the HikariCPConnectionProvider implementation, you could rather use DatasourceConnectionProviderImpl directly i.e. replace
.setProperty("hibernate.hikari.HikariDataSource", hikariDataSource)
with
DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl();
connectionProvider.setDataSource( hikariDataSource );
.setProperty("hibernate.connection.provider_class", connectionProvider)
You are clearly configuring Hibernate ORM in a programmatic fashion since you pass an object
HikariDataSourceas value somehow. Instead of changing theHikariCPConnectionProviderimplementation, you could rather useDatasourceConnectionProviderImpldirectly i.e. replace.setProperty("hibernate.hikari.HikariDataSource", hikariDataSource)with
DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl(); connectionProvider.setDataSource( hikariDataSource ); .setProperty("hibernate.connection.provider_class", connectionProvider)
Hi, I'm not following. Do you mean for us to extend DatasourceConnectionProviderImpl or to submit a PR for these changes you outlined above directly into DatasourceConnectionProviderImpl.
If you meant for us to extend DatasourceConnectionProviderImpl, then at what interaction would we override the base code with what you have suggested?
Have you looked at DatasourceConnectionProviderImpl?
Its hard to answer these usage questions without seeing your actual code. The important bit here is when/how you create the HikariDataSource relative to when/how you bootstrap Hibernate. But assuming "normal" start up, something like:
HikariDataSource hikariDatasource = ...;
SessionFactory = new Configuration()
.setProperty( "hibernate.connection.datasource", hikariDatasource )
...
.buildSessionFactory();