hibernate/hibernate-orm · error · ConfigurationException
Could not determine how to handle configuration value [name=
Error message
Could not determine how to handle configuration value [name=${name}, value=${value}(${value.getClass().getName()})] as Integer What it means
The nullable variant ConfigurationHelper.getInteger accepts null, Integer, or String values; blank/whitespace-only strings are trimmed and returned as null (empty values are ignored). Any other runtime type under the key (Long, Boolean, Double, custom object) throws this ConfigurationException. As with getInt, the message identifies the key, raw value, and concrete value class.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java:223
* @param name The config setting name.
* @param values The map of config values
*
* @return The value, or null if not found
*/
public static Integer getInteger(String name, Map<?,?> values) {
final Object value = values.get( name );
if ( value == null ) {
return null;
}
else if (value instanceof Integer integer) {
return integer;
}
else if (value instanceof String string) {
//empty values are ignored
final String trimmed = string.trim();
return trimmed.isEmpty() ? null : Integer.valueOf( trimmed );
}
throw new ConfigurationException(
"Could not determine how to handle configuration value [name=" + name +
", value=" + value + "(" + value.getClass().getName() + ")] as Integer"
);
}
public static long getLong(String name, Map<?,?> values, int defaultValue) {
final Object value = values.get( name );
if ( value == null ) {
return defaultValue;
}
else if (value instanceof Long number) {
return number;
}
else if (value instanceof String string) {
return Long.parseLong(string);
}
else {
throw new ConfigurationException(View on GitHub (pinned to fad1729dce)
Solutions
- Put the value as an Integer or as a numeric String; use an empty/blank string when you want the setting treated as absent (returns null)
- Normalize values from typed sources with String.valueOf(...) before they enter the map
- Check the message for name=<key> and the value class, then fix or remove that single entry
Example fix
// before
Object v = typedConfigSource.get("some.int.setting"); // may arrive as Long/Boolean
props.put("some.int.setting", v);
// after
Object v = typedConfigSource.get("some.int.setting");
props.put("some.int.setting",
v instanceof Integer || v instanceof String ? v : String.valueOf(v)); Defensive patterns
Strategy: validation
Validate before calling
for (Map.Entry<String,Object> e : props.entrySet()) {
Object v = e.getValue();
if (!(v == null || v instanceof Integer || v instanceof String)) {
e.setValue(String.valueOf(v));
}
} Type guard
static boolean isIntegerCoercible(Object v) {
if (v == null || v instanceof Integer) return true;
if (v instanceof String s) {
String t = s.trim();
return t.isEmpty() || t.chars().allMatch(c -> c == '-' || Character.isDigit(c));
}
return false;
} Prevention
- Keep Integer-typed settings as Integer or numeric String; blank strings intentionally mean 'absent'
- Do not reuse Boolean values for Integer-typed keys
- Validate the config map once at application start
When it happens
Trigger: Putting a non-Integer, non-String object under a key that Hibernate later reads with getInteger, e.g. props.put("some.int.setting", Boolean.TRUE) or a Double from a typed config bridge; a Long literal autoboxed from code like props.put(key, 100L).
Common situations: Typed config frameworks (Spring Environment adapters, microprofile config) feeding the JPA integration map; integration tests that set flags as Boolean for keys Hibernate treats as Integer; mixed-type maps assembled from several sources.
Related errors
- Could not determine how to handle configuration value [name=
- Could not determine how to handle configuration value [name=
- The {storageEngine} storage engine is not supported
- Unrecognized graph_parser_mode value : " + graphParserMode +
- Could not instantiate event listener '{}'
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/956f208f2c29523e.
Report an issue: GitHub.