在使用ibatis和spring时发生的错误

加刚 2011-12-16 10:55:37
org.springframework.dao.DataIntegrityViolationException: SqlMapClient operation; SQL [];
--- The error occurred in com/njty/dao/ibatis/sqlmap/LineRunSQLMap.xml.
--- The error occurred while applying a parameter map.
--- Check the LineRunSQL.queryOnLineCarCnt-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: ORA-01722: 无效数字
; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/njty/dao/ibatis/sqlmap/LineRunSQLMap.xml.

我的bean
private String busLineName;
public String getBusLineName() {
return busLineName;
}
public void setBusLineName(String busLineName) {
this.busLineName = busLineName;
}

sql.xml
<select id="queryNo" parameterClass="busQueryBean" resultMap="locatCarNo">
<![CDATA[
select count(no) as cnt, no, inorout from tab_devcurrstation a0
inner join tybus_his.tab_gpshisdata_current a on a0.devidstr=a.devidstr
where (
a0.lineid in (select t.busline_no from tab_buslines t where t.busline_name like #busLineName# ||'%')
or
a0.lineid in (select t.busline_id from tab_buslines t where t.busline_name like #busLineName# ||'%')
)
and a0.onordown=#inDown#
group by a0.no ,a0.inorout
]]>
</select>
参数传递不进去,改成 '$busLineName$'就正确了。原来是可以用的,实在是不理解,为什么string类型传进去出问题啊!!!!!!!
...全文
146 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jun25180 2011-12-25
  • 打赏
  • 举报
回复
用#标起来,#代表'的意思,建议去看相关资料
lxhuang0911 2011-12-23
  • 打赏
  • 举报
回复
在生成sql时ibatis会把参数传递(#)变成?,再将参数替换如('a');
而直接引用就是直接替换成a 不知道你懂没
加刚 2011-12-23
  • 打赏
  • 举报
回复
还能再讲的详细点啊?我知道#是参数传递,$是直接引用值
大白菜丸子 2011-12-16
  • 打赏
  • 举报
回复
ibatis里like需要用$标记是以字符串方式输出,#是以参数方式输出

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧