2010-3-17 17:06:10 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
com.ibatis.sqlmap.client.SqlMapException: There is no statement named queryAllArea in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:606)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:122)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:99)
at cn.sh.ideal.collectionAnother.dao.impl.CollectionAnotherImpl.getAllArea(CollectionAnotherImpl.java:16)
at cn.sh.ideal.collectionAnother.action.CollectionAction.basic(CollectionAction.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
经常发生这种问题,其实是写代码不严谨造成的。忘记将相应的sqlMap文件名称和路径在sqlMapConfig(sql-map-config.xml)配置文件中进行配置。
主要体现在sqlmap文件很多的时候,被分成两个独立的,如:
<sqlMap namespace="promotion">
<select id="query_total_num" parameterClass="map" resultClass="int"> </select>
</sqlMap>
和
<sqlMap>
<typeAlias alias="sql.date" type="java.sql.Date"/>
<!-- 键值对象 共通 -->
<typeAlias alias="" type="com.model.KeyValueBean"/>
</sqlMap>
这两个文件要注意第一个的命名空间namespace和sql语句的id,第二个注意alias和type的路径,这些问题。
而在sqlMapConfig(sql-map-config.xml)配置文件中
<sqlMapConfig>
<settings cacheModelsEnabled = "false"
enhancementEnabled = "true"
lazyLoadingEnabled = "true"
errorTracingEnabled = "true"
useStatementNamespaces = "true"
maxRequests = "512"
maxSessions = "128"
maxTransactions = "16"/>
<!-- clob字段处理 -->
<typeHandler jdbcType="CLOB" javaType="java.lang.String" callback="org.springframework.orm.ibatis.support.ClobStringTypeHandler" />
<!-- 公共 -->
<sqlMap resource = "sqlmaps/ibatis-common.xml" />
</sqlMapConfig>
开始的参数配置,后面sqlMap中resource的注入出现的路径问题。