`

Ibatis :The error occurred while applying a parameter map.

    博客分类:
  • WARN
阅读更多
项目需求变更在修改源程序时,要涉及数据库变动,大刀阔斧一般之后报错了!
数据库表列添加case_parentno等字段
在Bo/vo case.java 添加 caseParentNo 属性
在sqlMap case.xml 添加了相应的结果集的映射:
ResultMap中给出的配置字段


<resultMap id="Result" class="CaseObject">
....
			   <result property="caseParentNo" column="case_parentno" nullValue=""/>
		
	
....
</resultMap>


返回的数据集也做了相应修改


SELECT c.GID as case_id,[case_no],[case_serv_NO],[case_Depa_No],[case_user_id],[case_Bjuserid],[case_statusId],[case_TimeLimit]
			      ,[case_ServicePrice],[case_note],[case_TypeId],[case_number],[case_PriceFlag],[case_parentno],[case_subno] ,[case_HandleDays] 
			    .... [color=red]c.caseParentNo[/color]
	  		FROM [t_Case] c,t_caseType ct,t_caseStatus cs,t_service s,t_department dept,t_users u,t_villtype v
	  		WHERE c.case_typeid=ct.type_id 
		  		and c.case_statusid=cs.casestatus_id 
		  		and c.case_serv_no=s.serv_no 
	  			and c.case_depa_no=dept.depa_no 
	  			and c.case_user_id=u.user_id
	  			and c.case_convType=v.type_id




呵呵,结果报错了...

ERROR [http-8080-11] - SqlMapClient operation; [color=red]bad SQL grammar []; [/color]nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred while applying a parameter map.  
--- Check the Case.getPageList-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: [color=red]列名 'caseParentNo' 无效。[/color]ERROR [http-8080-11] - 执行:class com.ving.xzfw.service.impl.CaseServiceImpl.getPageCaseList()方法出错!
ERROR [http-8080-11] - 
ERROR [http-8080-8] - 执锟叫o拷class com.ving.xzfw.persistence.impl.CaseDaoImpl.getPageList()锟斤拷锟斤拷锟斤拷?
ERROR [http-8080-8] - SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred while applying a parameter map.  
--- Check the Case.getPageList-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 列名 'caseParentNo' 无效。
ERROR [http-8080-8] - 执行:class com.ving.xzfw.service.impl.CaseServiceImpl.getPageCaseList()方法出错!
ERROR [http-8080-8] - 
ERROR [http-8080-11] - 调用getCaseInfos方法失败
ERROR [http-8080-8] - 调用getCaseInfos方法失败


遇到“The error occurred while applying a parameter map”这种错误,首先想到的是字段对应的错误


.在使用ResultMap的时候,你要特别注意,如果你在ResultMap中给出的配置字段,但是你返回的数据集的时候却没有返回这个字段,那程序将出抛出异常。但是相反的,如果你返回了一些字段,却没有在ResultMap给出配置定义的话,那么那些字段将不会被处理而不会给你任何的提示,相当没有查询出这些字段。你要特别注意这个问题。


我们在排除错误时需要充分仔细分析控制台给予的信息,实际上控制台已经给予我们解决错误的方向!及时发现问题并予以解决问题的能力这就展现一个程序员的功底啦

很明显的bad SQL grammar  SQLServerException: 列名 'caseParentNo' 无效。

把这个语句粘贴到数据库做个测试,果然报错了。。。
消息 207,级别 16,状态 1,第 12 行
列名 'caseParentNo' 无效。(替换一下:case_parentno)
呵呵,找到原因喽,这样的错误我们在做ibatis 开发时经常会遇到,希望给予自己警戒!
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics