1 使用map <select id="selectRole" parameterType="map" resultType="RoleMap"> SELECT id, roleName, note FROM role WHERE roleName LIKE Concat('%',#{roleName},'%') and note like Concat('%',#{note},'%') </select> 在接口中如下定…
动态sql where if where可以自动处理第一个and. <!-- 根据id查询用户信息 --> <!-- public User findUserById(int id); --> <select id="findUserById" parameterType="user" resultType="user"> select * from user <!-- 当有if条件成立时,where会自…
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.depp…
Available parameters are [2, 1, 0, param1, param2, param3] <select id="loginByTeacher" parameterType="String" resultType="User"> SELECT * FROM `user` WHERE LoginID=#{0} and LoginPwd=#{1} AND Role=2 </select>…
http://www.cnblogs.com/littleCode/p/3727476.html oracle数据库: SELECT * FROM user WHERE name like CONCAT('%',#{name},'%') 或 SELECT * FROM user WHERE name like '%'||#{name}||'%' SQLServer数据库: SELECT * FROM user WHERE name like '%'+#{name}+'%' mysql数据库: S…
oracle数据库: SELECT * FROM user WHERE name like CONCAT('%',#{name},'%') 或 SELECT * FROM user WHERE name like '%'||#{name}||'%' SQLServer数据库: SELECT * FROM user WHERE name like '%'+#{name}+'%' mysql数据库: SELECT * FROM user WHERE name like CONCAT('%',#{na…
原生写法 eg: select * from user where username like '%${value}%' 注意: ${value}里面必须要写value,不然会报错 oracle数据库: SELECT * FROM user WHERE name like CONCAT('%',#{name},'%') 或 : SELECT * FROM user WHERE name like '%'||#{name}||'%' SQLServer数据库: SELECT * FROM…
在开发的时候,mybatisl中使用in的时候会遇到一些问题,如果我们传的参数是String类型,以“,”来进行隔开的,例如:参数是0,1,2字符串,mybatis中的语句如下 <select id="findByName" parameterType="string" resultType="com.domain.Factory"> SELECT * FROM FACTORY WHERE ID IN (#{ids}) </se…