这是我写的sql语句
<select id="selectByDynamic" parameterType="Student" resultType="Student">
select *from sudent where
<if test="sno!=null">
sno=#{sno}
</if>
<if test="sname!=null">
and sname=#{sname}
</if>
</select>
这是日志
DEBUG [main] (JdbcTransaction.java:136) - Opening JDBC Connection
DEBUG [main] (PooledDataSource.java:387) - Created connection 1526838264.
DEBUG [main] (JdbcTransaction.java:100) - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@5b01b3f8]
DEBUG [main] (BaseJdbcLogger.java:145) - ==> Preparing: select *from sudent where sno=? and sname=?
DEBUG [main] (BaseJdbcLogger.java:145) - ==> Parameters: 1414855328(String), 刘梅红(String)
这是代码,执行到添加姓名的地方就不执行了,我觉得应该是mapper的动态sql语句有问题,但是我刚学习这个不知道这个语句又什么问题
public void testDynamic() throws Exception{
SqlSessionFactory ssf=getSqlSessionFactory();
SqlSession ss=ssf.openSession();
StudentMapper cm=ss.getMapper(StudentMapper.class);
Student student=new Student();
student.setSno("1414855328");
student.setSname("刘梅红");
List<Student> listStudent= cm.selectByDynamic(student);
listStudent.forEach(x->System.out.println());
ss.close();