mybatis/mybatis-3 · error · UnsupportedOperationException
'" + this.getClass() + "' must override the default method '
Error message
'" + this.getClass() + "' must override the default method 'getGenericGetterType()'.
What it means
The getter-side twin of getGenericSetterType: ObjectWrapper.getGenericGetterType(String) is a default method whose body only throws UnsupportedOperationException naming the class that must override it. It resolves the full generic Type of a readable property for generic-aware TypeHandler selection; wrappers that don't implement it (e.g. CollectionWrapper) throw when it is called.
Source
Thrown at src/main/java/org/apache/ibatis/reflection/wrapper/ObjectWrapper.java:51
void set(PropertyTokenizer prop, Object value);
String findProperty(String name, boolean useCamelCaseMapping);
String[] getGetterNames();
String[] getSetterNames();
Class<?> getSetterType(String name);
Class<?> getGetterType(String name);
default Entry<Type, Class<?>> getGenericSetterType(String name) {
throw new UnsupportedOperationException(
"'" + this.getClass() + "' must override the default method 'getGenericSetterType()'.");
}
default Entry<Type, Class<?>> getGenericGetterType(String name) {
throw new UnsupportedOperationException(
"'" + this.getClass() + "' must override the default method 'getGenericGetterType()'.");
}
boolean hasSetter(String name);
boolean hasGetter(String name);
MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory);
boolean isCollection();
void add(Object element);
<E> void addAll(List<E> element);
}
View on GitHub (pinned to 008069adb1)
Solutions
- Override getGenericGetterType(String name) in your custom ObjectWrapper (typically delegating to MetaClass/Reflector generic info)
- Prefer BeanWrapper/MapWrapper, which override the method, when generic resolution is required
- Do not call generic property type methods on collection wrappers that have no properties
Example fix
// before
class MyWrapper implements ObjectWrapper { /* no getGenericGetterType */ }
// after
@Override
public Entry<Type, Class<?>> getGenericGetterType(String name) {
Class<?> raw = metaClass.getGetterType(name);
return Map.Entry.entry(raw, raw);
} Defensive patterns
Strategy: validation
Validate before calling
ObjectWrapper w = metaObject.getObjectWrapper();
if (w instanceof org.apache.ibatis.reflection.wrapper.BeanWrapper
|| w instanceof org.apache.ibatis.reflection.wrapper.MapWrapper) {
var t = w.getGenericGetterType(name);
} Prevention
- Implement getGenericGetterType in custom ObjectWrapper implementations
- Review ObjectWrapper default methods after each MyBatis 3.5.x upgrade
- Avoid generic-type queries on collection wrappers that have no properties
When it happens
Trigger: metaObject.getObjectWrapper().getGenericGetterType(name) invoked on a wrapper without the override; MyBatis parameter/result resolution paths that need the generic element type of a property (e.g. List<Item> items) running against a custom or minimal ObjectWrapper.
Common situations: Custom ObjectWrapper implementations predating the 3.5.x generic-type APIs; upgrading MyBatis where the framework began calling getGenericGetterType during parameter handling; direct API use in reflection utilities.
Related errors
- '" + this.getClass() + "' must override the default method '
- The 2nd arg must be Class or ParameterizedType, but was: {}
- The DefaultObjectWrapperFactory should never be called to pr
- Error creating instance. Cause: {cause}
- Error in result map '{resultMapId}'. Failed to find a constr
AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14).
Data as JSON: /api/errors/e1e21be2c9c11ce6.
Report an issue: GitHub.