Skip to content

Setter with generics and without a getter produces an exception #755

@tivv

Description

@tivv

MyBatis version

3.2.4, master code seems to be the same

Database vendor and version

Oracle, but not DB specific

Test case & Steps to reproduce

interface BeanInterface<T> {
 void setProperty(T value);
}
class BeanClass implements BeanInterface<String> {
 void setProperty(String value);
}

now use bean of BeanClass in mapping

Expected result

mapping works

Actual result

org.apache.ibatis.reflection.ReflectionException: Illegal overloaded setter method with ambiguous type for property property in class interface package.BeanInterface. This breaks the JavaBeans specification and can cause unpredicatble results.

Workaround

Introduce a getter

class BeanClass implements BeanInterface<String> {
 void setProperty(String value);
 String getProperty();
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions