/**
* 通过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());
}
|