Mybatis --06.mybatis动态代理Dao接口实现CRUD操作

使用mybatis动态代理Dao实现CRUD操作要求:

1、持久层接口(UserDao)和持久层接口的映射配置(UserDao.xml)必须在相同的包下 
2、持久层映射配置中mapper标签的namespace属性取值必须是持久层接口的全限定类名 
3、SQL语句的配置标签
        select  from tb_user where id = #{id}
    

    

    
        INSERT INTO tb_user (
        user_name,
        password,
        name,
        age,
        sex,
        birthday,
        created,
        updated
        )
        VALUES
        (
        #{userName},
        #{password},
        #{name},
        #{age},
        #{sex},
        #{birthday},
        NOW(),
        NOW()
        )
    

    
        UPDATE tb_user set
        user_name = #{userName},
        password = #{password},
        name = #{name},
        age = #{age},
        sex = #{sex},
        birthday = #{birthday},
        updated = NOW()
        WHERE
        id = #{id}
    

    
        delete from tb_user where
        id = #{id}
    

    
    

注意:mapper中的nameSpace是持久层接口全限定名称

SQL语句的配置标签