Skip to content

Commit

Permalink
Simplify connection handling setup and add a note about quarkusio#7242
Browse files Browse the repository at this point in the history
DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT, on top of being less
efficient, also leads to resource leaks (that are caught by Agroal,
but still).

Signed-off-by: Yoann Rodière <yoann@hibernate.org>
  • Loading branch information
yrodiere committed Feb 22, 2021
1 parent 13696e9 commit d39f754
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,18 @@ private MergedSettings mergeSettings(PersistenceUnitDescriptor persistenceUnit)
//Agroal already does disable auto-commit, so Hibernate ORM should trust that:
cfg.put(AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT, Boolean.TRUE.toString());

/**
/*
* Set CONNECTION_HANDLING to DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION
* as it generally performs better, at no known drawbacks.
* This is a new mode in Hibernate ORM, it might become the default in the future.
*
* Note: other connection handling modes lead to leaked resources, statements in particular.
* See https://github.com/quarkusio/quarkus/issues/7242, https://github.com/quarkusio/quarkus/issues/13273
*
* @see org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode
*/
{
final Object explicitSetting = cfg.get(AvailableSettings.CONNECTION_HANDLING);
if (explicitSetting == null) {
cfg.put(AvailableSettings.CONNECTION_HANDLING,
PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION);
}
}
cfg.putIfAbsent(AvailableSettings.CONNECTION_HANDLING,
PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION);

if (readBooleanConfigurationValue(cfg, WRAP_RESULT_SETS)) {
LOG.warn("Wrapping result sets is not supported. Setting " + WRAP_RESULT_SETS + " to false.");
Expand Down

0 comments on commit d39f754

Please sign in to comment.