Mybatis的动态代理模式

mybatis的动态代理需要遵循4个规则:

  1.xml文件中的namespace的值为接口类的全限命名

  2.statement的id要跟接口的方法名相同。

  3.statement的parameterType要跟接口的方法的参数的类型相同。

  4.statement的resultType要跟接口方法的返回值类型相同。

 

接口:

  

    public Student selectStuById(int id);

xml文件:

<select id="selectStuById" resultType="com.neuedu.bean.Student"  parameterType="Integer">
        select * from stu1 where sid = #{sid}
    </select>

 

posted @ 2017-09-04 20:53  薛小生  阅读(952)  评论(0编辑  收藏  举报