The following exception occurred today when executing SQL statements using MyBatis:
The following SQL statement configuration information is executed:
<select id= "Getcolumnsbytablename" parametertype= "String" resulttype= "java.util.List" >
Select T.column_name from User_tab_columns t where T.tablename=#{tablename,jdbctype=varchar}
</select>
The corresponding DAO interface code is:
Public list<string> getcolumnsbytablename (String tableName);
should read:
<select id= "Getcolumnsbytablename" parametertype= "string" resulttype= "string" > select T.column_name F Rom User_tab_columns t where t.tablename=#{tablename,jdbctype=varchar}</select>
The reason is that Resulttype represents the element type in the list, not the list itself, because it is declared by the method in the DAO (marked red)
Public list<string> getcolumnsbytablename (String tableName);
It's confusing.
Remember: Resulttype returns the element type in the collection, not the collection itself
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MyBatis Solutions for Java.lang.UnsupportedOperationException anomalies