{"record":{"id":"9c9c070d114a9e7f","repo":"mybatis/mybatis-3","slug":"this-getclass-must-override-the-defaul","errorCode":null,"errorMessage":"'\" + this.getClass() + \"' must override the default method 'getGenericSetterType()'.","messagePattern":"'\" \\+ this\\.getClass\\(\\) \\+ \"' must override the default method 'getGenericSetterType\\(\\)'\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/reflection/wrapper/ObjectWrapper.java","lineNumber":46,"sourceCode":" */\npublic interface ObjectWrapper {\n\n  Object get(PropertyTokenizer prop);\n\n  void set(PropertyTokenizer prop, Object value);\n\n  String findProperty(String name, boolean useCamelCaseMapping);\n\n  String[] getGetterNames();\n\n  String[] getSetterNames();\n\n  Class<?> getSetterType(String name);\n\n  Class<?> getGetterType(String name);\n\n  default Entry<Type, Class<?>> getGenericSetterType(String name) {\n    throw new UnsupportedOperationException(\n        \"'\" + this.getClass() + \"' must override the default method 'getGenericSetterType()'.\");\n  }\n\n  default Entry<Type, Class<?>> getGenericGetterType(String name) {\n    throw new UnsupportedOperationException(\n        \"'\" + this.getClass() + \"' must override the default method 'getGenericGetterType()'.\");\n  }\n\n  boolean hasSetter(String name);\n\n  boolean hasGetter(String name);\n\n  MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory);\n\n  boolean isCollection();\n\n  void add(Object element);\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/reflection/wrapper/ObjectWrapper.java#L28-L64","documentation":"ObjectWrapper.getGenericSetterType(String) is a Java 8 default method that only exists to be overridden; the default body throws UnsupportedOperationException telling which class failed to override it. It resolves the full generic Type of a writable property (needed for precise TypeHandler selection with generics, e.g. List<String>). BeanWrapper and MapWrapper override it; wrappers like CollectionWrapper do not, so calling it on those throws.","triggerScenarios":"Calling metaObject.getObjectWrapper().getGenericSetterType(name) on a wrapper that did not override it (e.g. CollectionWrapper); MyBatis internals resolving generic setter types (DefaultParameterHandler parameter setting with generic properties) against a custom ObjectWrapper implementation missing the override.","commonSituations":"Writing a custom ObjectWrapper (custom wrapper factory setups) without implementing the newer default methods added in recent MyBatis 3.5.x releases; upgrading MyBatis where generic type resolution started calling this method.","solutions":["Override getGenericSetterType(String name) in your custom ObjectWrapper implementation (delegate to a Reflector/MetaClass lookup)","Use BeanWrapper/MapWrapper which already override it, instead of CollectionWrapper, when generic type resolution is needed","Avoid calling the generic variant on wrappers that cannot know setter types (collections)"],"exampleFix":"// before\nclass MyWrapper implements ObjectWrapper { /* no getGenericSetterType */ }\n\n// after\n@Override\npublic Entry<Type, Class<?>> getGenericSetterType(String name) {\n  return Map.Entry.entry(metaClass.getSetterType(name), metaClass.getSetterType(name));\n}","handlingStrategy":"validation","validationCode":"ObjectWrapper w = metaObject.getObjectWrapper();\n// only call on wrappers known to implement the generic API\nif (w instanceof org.apache.ibatis.reflection.wrapper.BeanWrapper\n    || w instanceof org.apache.ibatis.reflection.wrapper.MapWrapper) {\n  var t = w.getGenericSetterType(name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Implement getGenericSetterType in every custom ObjectWrapper","After MyBatis upgrades, recompile custom wrappers to catch new default-method contracts","Prefer delegating wrapper implementations to BeanWrapper/MapWrapper"],"tags":["reflection","spi","object-wrapper","generics","mybatis"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}