{"record":{"id":"6cb5b926ca49d66e","repo":"hibernate/hibernate-orm","slug":"could-not-determine-how-to-handle-configuration-va-6cb5b9","errorCode":null,"errorMessage":"Could not determine how to handle configuration value [name=${name}, value=${value}(${value.getClass().getName()})] as int","messagePattern":"Could not determine how to handle configuration value \\[name=(.+?), value=(.+?)\\((.+?)\\)\\] as int","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java","lineNumber":196,"sourceCode":"\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;\n\t\t}\n\t\telse if (value instanceof Integer integer) {\n\t\t\treturn integer;\n\t\t}\n\t\telse if (value instanceof String string) {\n\t\t\treturn Integer.parseInt(string);\n\t\t}\n\t\tthrow new ConfigurationException(\n\t\t\t\t\"Could not determine how to handle configuration value [name=\" + name +\n\t\t\t\t\t\t\", value=\" + value + \"(\" + value.getClass().getName() + \")] as int\"\n\t\t);\n\t}\n\n\t/**\n\t * Get the config value as an {@link Integer}\n\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, or null if not found\n\t */\n\tpublic static Integer getInteger(String name, Map<?,?> values) {\n\t\tfinal Object value = values.get( name );\n\t\tif ( value == null ) {\n\t\t\treturn null;\n\t\t}","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java#L178-L214","documentation":"ConfigurationHelper.getInt only accepts three shapes for a setting: null (use default), java.lang.Integer, or a String it can Integer.parseInt. Any other runtime type under the key (Long, Boolean, Double, enum, custom object) cannot be coerced, so Hibernate fails fast with this ConfigurationException instead of guessing. The message prints the offending key, its raw value, and the value's concrete class, so the bad entry is easy to locate.","triggerScenarios":"Building a SessionFactory/EntityManagerFactory from a Map where a numeric setting was stored as a boxed Long or another Number, e.g. settings.put(\"hibernate.jdbc.fetch_size\", 5_000L); or where a typed config source (YAML/microprofile config loader) delivers a Boolean/Double for a key Hibernate reads via getInt().","commonSituations":"Programmatic property maps using autoboxed long literals; typed configuration frameworks that parse \"5000\" into Long before it reaches Hibernate; copying properties between systems where the value type changes; unit tests injecting typed property values.","solutions":["Store the value as an Integer (settings.put(key, 5000)) or as a numeric String (settings.put(key, \"5000\"))","If the value comes from a typed external source, convert with String.valueOf(...) before putting it into the Hibernate properties map","Read the message: it contains name=<key>, value=<raw value> and the value class - fix exactly that one entry"],"exampleFix":"// before\nMap<String,Object> settings = new HashMap<>();\nsettings.put(\"hibernate.jdbc.fetch_size\", 5_000L); // Long -> ConfigurationException\n\n// after\nsettings.put(\"hibernate.jdbc.fetch_size\", 5_000);   // Integer\n// or\nsettings.put(\"hibernate.jdbc.fetch_size\", \"5000\");  // numeric String","handlingStrategy":"validation","validationCode":"// Normalize the settings map before building the SessionFactory\nfor (Map.Entry<String,Object> e : settings.entrySet()) {\n    Object v = e.getValue();\n    if (!(v == null || v instanceof Integer || v instanceof String)) {\n        e.setValue(String.valueOf(v)); // getInt parses numeric Strings\n    }\n}","typeGuard":"static boolean isIntCoercible(Object v) {\n    if (v == null || v instanceof Integer) return true;\n    if (v instanceof String s) {\n        try { Integer.parseInt(s.trim()); return true; }\n        catch (NumberFormatException ignored) { }\n    }\n    return false;\n}","tryCatchPattern":null,"preventionTips":["Always write numeric Hibernate settings as int literals or plain Strings in the properties map","Assemble the map in one place so types are visible at a glance","Add a bootstrap smoke test (build the SessionFactory in CI) so type mistakes fail the build, not production"],"tags":["configuration","type-conversion","bootstrap"],"backgroundTag":"invalid-config-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}