mybatis sql语句获取不到参数
需要一个userId 我在Dao层this.getSqlSession().selectOne("userManage.retrieveUserDetail", input);执行前
syso了 input 里面是有userId的 为什么执行的时候userId 是null??
- Java code
<select id="retrieveUserDetail" parameterType="cdata" resultType="cdata"> <![CDATA[ SELECT u.user_id "userId", u.user_name "userName", u.password "password", u.email "email", u.phone_no "phoneNo", u.fax_no "faxNo", u.create_by "createBy", u.create_date "createDate", u.use_flag "useFlag", u.address "address", u.dept_id "deptId", d.DEPT_NAME "deptname", u.position "position", u.mobile_no "mobileNo", u.notes "notes", u.sub_dept_id "subDeptId", a.auth_code as "code" FROM T_user_m u ,t_auth_user a,t_dept_m d WHERE u.user_id = #{userId} and u.user_id=a.user_id and u.DEPT_ID=d.DEPT_ID ]]> </select>[解决办法]
WHERE u.user_id = #{userId}# and u.user_id=a.user_id and u.DEPT_ID=d.DEPT_ID
[解决办法]
cdata是什么类型,定义了别名吗?
建议参数用Map代替
parameterType="java.util.Map"
[解决办法]
错了
该
WHERE u.user_id = #userId# and u.user_id=a.user_id and u.DEPT_ID=d.DEPT_ID
[解决办法]
一个参数就用parameterType=“java.lang.String”