{"record":{"id":"539b6a0936032932","repo":"hibernate/hibernate-orm","slug":"could-not-determine-how-to-handle-configuration-va","errorCode":null,"errorMessage":"Could not determine how to handle configuration value [name=${name}, value=${value}] as boolean","messagePattern":"Could not determine how to handle configuration value \\[name=(.+?), value=(.+?)\\] as boolean","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java","lineNumber":170,"sourceCode":"\t *\n\t * @param name The config setting name.\n\t * @param values The map of config values\n\t *\n\t * @return The value.\n\t */\n\tpublic static Boolean getBooleanWrapper(String name, Map<?,?> values, Boolean defaultValue) {\n\t\tfinal Object value = values.get( name );\n\t\tif ( value == null ) {\n\t\t\treturn defaultValue;\n\t\t}\n\t\telse if (value instanceof Boolean bool) {\n\t\t\treturn bool;\n\t\t}\n\t\telse if (value instanceof String string) {\n\t\t\treturn Boolean.valueOf(string);\n\t\t}\n\t\telse {\n\t\t\tthrow new ConfigurationException(\n\t\t\t\t\t\"Could not determine how to handle configuration value [name=\" + name + \", value=\" + value + \"] as boolean\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the config value as an int\n\t *\n\t * @param name The config setting name.\n\t * @param values The map of config values\n\t * @param defaultValue The default value to use if not found\n\t *\n\t * @return The value.\n\t */\n\tpublic static int getInt(String name, Map<?,?> values, int defaultValue) {\n\t\tfinal Object value = values.get( name );\n\t\tif ( value == null ) {\n\t\t\treturn defaultValue;","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java#L152-L188","documentation":"ConfigurationHelper.getBooleanWrapper(name, values, default) is the Boolean-returning variant used for optional boolean settings. It accepts only null (default), Boolean, and String (via Boolean.valueOf — any string parses, unknown ones become false). Any other type — Integer, enum, custom object — triggers this ConfigurationException with the setting name and value inline.","triggerScenarios":"Calling getBooleanWrapper (or bootstrapping Hibernate with a setting it reads this way) where the config map holds a non-Boolean/non-String value, e.g. props.put(\"hibernate.format_sql\", Boolean.TRUE) is fine but props.put(..., 1) or an AtomicInteger/enum value throws.","commonSituations":"Typed config sources feeding the EntityManagerFactory properties map (Spring Environment resolves some values to Integer/enum); environment-variable bridges that produce Integers; tests building properties programmatically with the wrong boxed type.","solutions":["Use the name/value in the message to locate and fix the exact entry","Keep every value in Hibernate property maps either String or Boolean","Sanitize third-party config maps: value != null ? value.toString() : null before bootstrap","Add a startup assertion that validates boolean-typed settings in your own config layer"],"exampleFix":"// before\nprops.put( \"hibernate.format_sql\", 1 );\n// after\nprops.put( \"hibernate.format_sql\", Boolean.TRUE );\n// or defensive normalization for arbitrary sources\nprops.replaceAll( (k, v) -> v == null || v instanceof String || v instanceof Boolean ? v : v.toString() );","handlingStrategy":"validation","validationCode":"// Reject or coerce non-Boolean/non-String values up front\nstatic void validateBooleanSetting(String name, Map<?, ?> values) {\n    Object v = values.get( name );\n    if ( v != null && !( v instanceof Boolean ) && !( v instanceof String ) ) {\n        throw new ConfigurationException( name + \" must be Boolean or String, got: \" + v.getClass().getName() );\n    }\n}","typeGuard":"static boolean isBooleanConfigValue(Object v) {\n    return v == null || v instanceof Boolean || v instanceof String;\n}","tryCatchPattern":"try {\n    Boolean flag = ConfigurationHelper.getBooleanWrapper( name, values, null );\n} catch ( ConfigurationException e ) {\n    // the message names the offending setting: convert that value to String and rebuild\n}","preventionTips":["Keep EntityManagerFactory property maps homogeneous: String (or Boolean) values only","When merging Spring/env/YAML sources, stringify every value before bootstrap","Write a config-validation unit test that runs the whole property map through type checks"],"tags":["hibernate","configuration","type-mismatch","bootstrap","properties"],"backgroundTag":"invalid-configuration-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}