我无法在文档中看到任何与我的问题相关的内容,并且在部署它后,我的应用程序无法正常工作(稍后会详细介绍)。我正在尝试做类似的事情
<select id="getLookupRows" parameterType="map" resultMap="lookupMap">
select id, name, active, valid
from #{table}
</select>
在 MyBatis 中。我有许多具有共享列的查找表,因此视图级别的用户确定最终使用哪个查找表。我尝试执行 getLookupRows 时遇到的错误是
Cause: org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter table of statement info.pureshasta.mapper.LookupMapper.getLookupRows
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:77)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:69)
org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:85)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:65)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
$Proxy15.getLookupRows(Unknown Source)
info.pureshasta.service.FieldTitleService.getLookupRows(FieldTitleService.java:33)
我的映射器界面如下:
List<Lookup> getLookupRows(@Param("specificColumn") String specificColumn,
@Param("table") String table);
所以我们知道我正在尝试将一个字符串传递给这个查询,没什么特别的。我有专门的专栏,因为那将是我的下一个任务。实际上,每个查找表的列之一是唯一的,因此我必须调用适当的 specificColumn,但如果我可以让表参数和 FROM 子句正常工作,我会非常高兴。