Skip to content

Commit 204f53d

Browse files
committed
unbreak Configuration.mergeProperties()
I broke this two years ago, but nobody ever noticed since it has no callers
1 parent b8ed5ad commit 204f53d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,18 +1268,22 @@ public Map<String, NamedProcedureCallDefinition> getNamedProcedureCallMap() {
12681268
}
12691269

12701270
/**
1271-
* Adds the incoming properties to the internal properties structure, as
1272-
* long as the internal structure does not already contain an entry for
1273-
* the given key.
1271+
* Adds the incoming properties to the internal properties structure,
1272+
* as long as the internal structure does <em>not</em> already contain
1273+
* an entry for the given key. If a given property is already set in
1274+
* this {@code Configuration}, ignore the setting specified in the
1275+
* argument {@link Properties} object.
1276+
*
1277+
* @apiNote You're probably looking for {@link #addProperties(Properties)}.
12741278
*
12751279
* @param properties The properties to merge
12761280
*
12771281
* @return {@code this} for method chaining
12781282
*/
12791283
public Configuration mergeProperties(Properties properties) {
1280-
for ( Map.Entry<Object,Object> entry : properties.entrySet() ) {
1281-
if ( !properties.containsKey( entry.getKey() ) ) {
1282-
properties.setProperty( (String) entry.getKey(), (String) entry.getValue() );
1284+
for ( String property : properties.stringPropertyNames() ) {
1285+
if ( !this.properties.containsKey( property ) ) {
1286+
this.properties.setProperty( property, properties.getProperty( property ) );
12831287
}
12841288
}
12851289
return this;

0 commit comments

Comments
 (0)