//获取sqlSession对象,本对象可以编译和执行sql代码
SqlSession sqlSession = factory.openSession();
//注意,这里使用的方法与 getAll 的方法不一样哦,因为这个需要传入参数。
Student student = sqlSession.selectOne("ll.getById",1);
System.out.println(student);
//关闭sqlSession对象
sqlSession.close();
}
}
> 测试结果,这样表示正确哦!

[]( )按学生名称模糊查询
-------------------------------------------------------------------------
> 按照学生名称模糊查询这个功能也是很常见的哦!
> 接下来我们就来完成它吧!
> 首先我们依旧修改StudentMapper.xml文件。
<select id="getByName" parameterType="string" resultType="com.longlong.pojo.Student">
select id,name,email,age
from student
where name like '%${name}%'
</select>
> 接下来就可以编写测试类了。加入以下代码。本次操作和第