mybatis传递多个参数值(转)
Mybatis传递多个参数
ibatis3如何传递多个参数有两个方法:一种是使用Map,另一种是使用JavaBean。
<!-- 使用HashMap传递多个参数 parameterType 可以是别名或完全限定名 ,map->java.util.Map,这两个都是可以的 --> <selectid= "selectBlogByMap" parameterType= "map" resultType= "Blog" > SELECT t.ID, t.title, t.content FROM blog t WHERE t.title = #{h_title} AND t.content =#{h_content} </select> <!-- 使用JavaBean传递多个参数 --> <selectid= "selectBlogByBean" parameterType= "Blog" resultType= "Blog" > SELECT t.ID, t.title, t.content FROM blog t WHERE t.title = #{title} AND t.content =#{content} </select> |
/** * 通过Map传递多个参数 */ @Test public void testSelectByMap() { SqlSession session = sqlSessionFactory.openSession(); Map<String, Object> param= new HashMap<String, Object>(); param.put( "h_title" , "oracle" ); param.put( "h_content" , "使用序列!" ); Blog blog = (Blog)session.selectOne( "cn.enjoylife.BlogMapper.selectBlogByMap" ,param); session.close(); System.out.println( "blog title:" +blog.getTitle()); } /** * 通过JavaBean传递多个参数 */ @Test 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()); } |
mybatis传递多个参数值(转)的更多相关文章
- mybatis 传递参数的方法总结
有三种mybatis传递参数的方式: 第一种 mybatis传入参数是有序号的,可以直接用序号取得参数 User selectUser(String name,String area); 可以在xml ...
- MyBatis传递参数
MyBatis传递参数 一.使用 map 接口传递参数 在 MyBatis 中允许 map 接口通过键值对传递多个参数,把接口方法定义为 : public List<Role> findR ...
- Mybatis传递多个参数的4种方式(干货)
Mybatis传递多个参数的4种方式(干货)-----https://blog.csdn.net/youanyyou/article/details/79406486
- Mybatis传递多个参数的几种方式
顺序传参法 public User selectUser(String name, int deptId); <select id="selectUser" resultMa ...
- mybatis传递参数到mapping.xml
第一种方案 ,通过序号传递 DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id ...
- Mybatis 传递多个参数
Mybatis提供了4种传递多个参数的方法: 1 Map sql语句 接口 调用方法 这个方法虽然简单易用,但是存在一个弊端:Map存储的元素是键值对,可读性不好. 2 注解 使用MyBatis的参数 ...
- Mybatis传递List集合
完整错误如下: org.apache.ibatis.binding.BindingException: Parameter ‘customerIdList’ not found. Available ...
- Mybatis传递多个参数
方法一: //DAO层的函数方法Public User selectUser(String name,String area); 对应的Mapper.xml <select id="s ...
- Mybatis传递多个参数的解决办法(三种)
第一种方案 DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id="s ...
随机推荐
- Hive命令详解
http://blog.itpub.net/22778222/viewspace-1119892/ 官方文档翻译 http://blog.csdn.net/hguisu/article/detail ...
- Java 使用StringBuffer注意
Stringbuffer使用注意 问题背景: 模拟客户端使用Socket请求服务器核心系统,核心系统正常响应,内容较大,近2715KB,大于2.6M多. 使用指定编码GBK来接收响应内容到过程中没 ...
- VueJS自定义全局和局部指令
除了默认设置的核心指令( v-model 和 v-show ), Vue 也允许注册自定义指令. 使用directive自定义全局指令 下面我们注册一个全局指令 v-focus, 该指令的功能是在页面 ...
- Cocos2d-x 3.1.1 学习日志2--error:仅仅有静态常量整型数据成员才干够在类中初始化
今天遇到比較低端的一个问题,就是成员的初始化问题,编译器也无法验证,不同的编译器有些能过有些不能过,我也不知道为什么,总是我们以vs为准吧,以为我们用的环境就是它,话不多说.解决方式例如以下: ...
- Bootstrap学习速查表(二) 排版及表格
一.h1~h6标签 固定不同级别标题字体大小,h1=36px,h2=30px,h3=24px,h4=18px,h5=14px和h6=12px. 1.重新设置了margin-top和margin-bot ...
- Oracle SQL性能优化 - 根据大表关联更新小表
需求: 小表数据量20w条左右,大表数据量在4kw条左右,需要根据大表筛选出150w条左右的数据并关联更新小表中5k左右的数据. 性能问题: 对筛选条件中涉及的字段加index后,如下常规的updat ...
- Erlang节点重启导致的incarnation问题(转)
转自霸爷的博客: 转载自系统技术非业余研究 本文链接地址: Erlang节点重启导致的incarnation问题 遇到个问题, =ERROR REPORT==== 10-Mar-2016::09:44 ...
- 高速修复汉澳sinox命令解释程序bash shell漏洞
bash是linux默认命令行管理程序shell.汉澳 sinox也安装有,尽管sinox并没有默认使用bash.可是用户一旦使用就会可能被通过漏洞入侵,所以必须高速修复.尽管sinox使用freeb ...
- Continuously Integrate
 Continuously Integrate David Bartlett THE Build AS A "Big BAng" EvEnT in project develop ...
- H2 应用实例1
说明:本例子开发工具为NetBeans,jdk 1.7 进行测试说明 H2安装说明如下 1. H2数据库必要文件下载地址为: http://www.h2database.com (1) 下载截 ...