12
Using annotations in mybatis, can we have return type as normal map ?
Basically, I want something like this
@Select("select a, b from tableA")
public Map<String, String> getItems();
Where
mysql> select * from tableA;
+------+------+
| a | b |
+------+------+
| 1 | a |
| 2 | b |
| 3 | c |
+------+------+
mysql> desc tableA;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| a | varchar(10) | YES | | NULL | |
| b | varchar(10) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
Tried this
@Select("select a, b from tableA")
@MapKey("a)
public Map<String, String> getItems();
but it's giving below exception
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'a' in 'class java.lang.String'