mybatis传递多个参数
2017-11-13 16:42
357 查看
通过JavaBean传递多个参数 <select id="selectBlogByBean" parameterType="Blog" resultType="Blog"> select t.ID, t.title, t.content from blog t wheret.title = #{title} and t.content =#{content} </select> public void testSelectByBean() { SqlSession session = sqlSessionFactory.openSession(); Blog blog=new Blog(); blog.setTitle("oracle"); blog.setContent("使用序列!"); Blog newBlog = (Blog)session.selectOne("cn.enjoylife.BlogMapper.selectBlogByBean",blog); session.close(); System.out.println("new Blog ID:"+newBlog.getId()); }通过Map传递多个参数Dao层的函数方法
Public
User
selectUser(Map paramMap);
对应的Mapper.xml个人认为此方法不够直观,见到接口方法不能直接的知道要传的参数是什么。Dao层的函数方法
Public
User
selectUser(@param(“userName”)Stringname,@param(“userArea”)Stringarea);[/code]对应的Mapper.xml[/code]通过{}传递多个参数
DAO层的函数方法[/code]
Public
User
selectUser(String
name
,Stringarea);[/code]
对应的Mapper.xml
[/code]
[/code]其中,#{0}代表接收的是dao层中的第一个参数,#{1}代表dao层中第二参数,更多参数一致往后加即可。原文:https://www.2cto.com/database/201409/338155.html,https://yq.aliyun.com/articles/67832?spm=5176.8246799.0.0.mAaqch
相关文章推荐
- mybatis 传递参数的三种方式
- mybatis参数传递的问题
- mybatis补充教程之二:传递多个参数的方法(Multiple parameters)
- mybatis 传递多参数(不使用实体)
- mybatis 参数传递之默认命名
- mybatis 关联映射传递多参数方法
- @Param 注解在Mybatis中的使用 以及传递参数的三种方式
- Mybatis 3.0 参数的传递
- mybatis传递多个参数
- mybatis的三种参数传递映射方式总结
- mybatis学习日志(1) : mapper.xml传递两个及多个参数
- Mybatis参数传递
- MYBATIS 的参数传递及XML内使用
- Mybatis传递多个参数的4种方式(干货)
- mybatis详解-(9)参数传递
- mybatis 之参数传递
- mybatis 中sql语句传递多个参数
- mybatis 传递多个参数 --解决mybatis查询使用多个参数方法--javabean传统方法和map方法
- MyBatis传递多个参数的写法
- MyBatis传递多个参数的方法