From 204f53d3ba155c25720a8f12a89a98ff5f2300c1 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 24 Nov 2024 09:54:08 +0100 Subject: [PATCH] unbreak Configuration.mergeProperties() I broke this two years ago, but nobody ever noticed since it has no callers --- .../java/org/hibernate/cfg/Configuration.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 5bf0f11585..ff5932da18 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -1268,18 +1268,22 @@ public Map getNamedProcedureCallMap() { } /** - * Adds the incoming properties to the internal properties structure, as - * long as the internal structure does not already contain an entry for - * the given key. + * Adds the incoming properties to the internal properties structure, + * as long as the internal structure does not already contain + * an entry for the given key. If a given property is already set in + * this {@code Configuration}, ignore the setting specified in the + * argument {@link Properties} object. + * + * @apiNote You're probably looking for {@link #addProperties(Properties)}. * * @param properties The properties to merge * * @return {@code this} for method chaining */ public Configuration mergeProperties(Properties properties) { - for ( Map.Entry entry : properties.entrySet() ) { - if ( !properties.containsKey( entry.getKey() ) ) { - properties.setProperty( (String) entry.getKey(), (String) entry.getValue() ); + for ( String property : properties.stringPropertyNames() ) { + if ( !this.properties.containsKey( property ) ) { + this.properties.setProperty( property, properties.getProperty( property ) ); } } return this;