详细解决方案
mybatis 传参查询急解决方法
热度:5073 发布时间:2013-02-25 21:05:29
Map<String,Object> m=new HashMap<String,Object>();
if (name !=null&&name != "")
m.put("name", name);
m.put("start", p.getStart());
m.put("max", p.getPageSize());
List<Employee> list=employeeMapper.getListPage(m);
-------------------->
<select id="getListPage" parameterType="map" resultMap="employeeMap">
<![CDATA[
select * from employee t1 join dept t2 on(t1.deptNo=t2.deptNo)
where
<if test="name != null"> t1.name = #{name}</if>
ORDER BY t1.id desc limit #{start}, #{max}
]]>
</select>
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
### The error may exist in com/employee/dao/EmployeeMapper.xml
### The error may involve com.employee.dao.EmployeeMapper.getListPage-Inline
### The error occurred while setting parameters
### SQL: select * from employee t1 join dept t2 on(t1.deptNo=t2.deptNo) where <if test="name!=null"> t1.name = ?</if> ORDER BY t1.id desc limit ?, ?
### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<if test="name!=null"> t1.name = null</if>
ORDER BY t1.id desc limit' at line 3
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
相关解决方案
- IE不支持JQuery吗?解决方法
- boa+cgi+sqlite3【基于web的数据采集并动态显示】解决方法
- spring3.1 + mybatis 回来null正常,返回结果前台接收不到
- cgi提取文件内容?解决方法
- mybatis 传参查询急解决方法
- java.lang.NoSuchMethodException: setId([Ljava.lang.String;)解决方法
- Spring + Mybatis 组合报错
- 求SSM分页 struts +spring+mybatis 给小弟我发个学习学习吧 多谢大神们
- 求解 struts+spring+mybatis sqlsession为空 debug发现没有执行set方法 检查配置好像没有关问题
- 求解 mybatis 动态sql语句 choose和if 一起用时,为什么只执行otherwise里面的Sql语句 求解
- s标签 图片src 当action 解析?解决方法
- Mybatis 自定义 Plugin(Interceptor) 研讨! 急
- CAPTCHA 模块中 ajax form 导致CAPTCHA session reuse attack detected异常,解决方法
- java编程思想.解决方法
- SSH框架导入struts,hibernate,spring分先后顺序吗>>解决方法
- myBatis 动态生成排序有关问题
- 关于遮罩层的。解决方法
- oracle 最近的时间(而不是前一天的时间) 跪求sql语句 。解决方法
- web service No services have been found.解决方法
- socket.connect(socketAddress,timeout ))解决方法
- description The requested resource (/gongqiu/goindex.action) is not available.解决方法
- javascript中===什么意思?解决方法
- struts工作流程~解决方法
- 求struts2玩的顺的人!解决方法
- Mybatis的mapper.是个接口?解决方法
- 求教一个关于两个list的类似求并集的算法。解决方法
- jquery+ajax网页被卡死,cpu爆掉! - -解决方法
- 怎样实现分页.解决方法
- MyBatis 读取 Mysql Blob类型的SQL如何写呢
- mapping.findForward()执行后,没有跳转页面?解决方法