diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java index f25513ba2e933..44ea98d385395 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java @@ -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.");