{"record":{"id":"b56deb0f4ad3f79c","repo":"hibernate/hibernate-orm","slug":"could-not-determine-how-to-handle-configuration-va-b56deb","errorCode":null,"errorMessage":"Could not determine how to handle configuration value [name=${name}, value=${value}(${value.getClass().getName()})] as long","messagePattern":"Could not determine how to handle configuration value \\[name=(.+?), value=(.+?)\\((.+?)\\)\\] as long","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java","lineNumber":241,"sourceCode":"\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 Integer\"\n\t\t);\n\t}\n\n\tpublic static long getLong(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 Long number) {\n\t\t\treturn number;\n\t\t}\n\t\telse if (value instanceof String string) {\n\t\t\treturn Long.parseLong(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 +\n\t\t\t\t\t\t\t\", value=\" + value + \"(\" + value.getClass().getName() + \")] as long\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Replace a property value with a starred version\n\t *\n\t * @param properties properties to check\n\t * @param key property to mask\n\t *\n\t * @return cloned and masked properties\n\t */\n\tpublic static Properties maskOut(Properties properties, String key) {\n\t\tfinal var clone = (Properties) properties.clone();\n\t\tif ( clone.get( key ) != null ) {\n\t\t\tclone.setProperty( key, \"****\" );","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java#L223-L259","documentation":"ConfigurationHelper.getLong accepts only null, java.lang.Long, or a parseable String. Unlike getInt it does NOT accept Integer - only `value instanceof Long` is checked - so a perfectly reasonable boxed Integer value throws this ConfigurationException. Everything else (Boolean, Double, Integer, custom types) also fails fast with the key, raw value, and value class in the message.","triggerScenarios":"settings.put(\"<long-typed setting>\", 3_600) where the literal autoboxes to Integer; or a typed config source delivering any Number that is not exactly Long; only \"3600\"-style Strings or 3_600L pass.","commonSituations":"Autoboxing surprises: writing a bare int literal for a long-typed setting; mixing properties between getInt-based and getLong-based consumers; refactors that change a literal from 100L to 100.","solutions":["Store the value as a Long literal (settings.put(key, 3_600L)) or as a numeric String (settings.put(key, \"3600\"))","If the source value is an int primitive/Integer, widen it explicitly: settings.put(key, (long) intValue)","Use the message's name=<key>, value=<raw value>, class info to find and fix the exact entry"],"exampleFix":"// before\nsettings.put(\"some.long.setting\", 3_600);  // autoboxes to Integer -> ConfigurationException\n\n// after\nsettings.put(\"some.long.setting\", 3_600L);   // Long\n// or\nsettings.put(\"some.long.setting\", \"3600\");   // numeric String","handlingStrategy":"validation","validationCode":"for (Map.Entry<String,Object> e : settings.entrySet()) {\n    Object v = e.getValue();\n    if (v instanceof Integer i) {\n        e.setValue(i.longValue()); // getLong rejects Integer\n    }\n}","typeGuard":"static boolean isLongCoercible(Object v) {\n    if (v == null || v instanceof Long) return true;\n    if (v instanceof String s) {\n        try { Long.parseLong(s.trim()); return true; }\n        catch (NumberFormatException ignored) { }\n    }\n    return false;\n}","tryCatchPattern":null,"preventionTips":["Always suffix long settings with L (3_600L, not 3_600)","Remember getLong accepts only Long or String - Integer is rejected","Widen int/Integer sources explicitly before putting them into long-typed settings"],"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"}