Mybatis动态表名查询用户信息

Mybatis动态表名查询用户信息
    //动态设置表名查询用户信息
    List<User> getUserList(@Param("tableName") String tableName);


    <select id="getUserList" resultType="User">
        select * from ${tableName}
    </select>


    @Test
    public void getUserListTest(){
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        SpecialSQLMapper mapper = sqlSession.getMapper(SpecialSQLMapper.class);

        List<User> list = mapper.getUserList("t_user");
        list.forEach(System.out::println);
    }

你可能感兴趣的:(Java,mybatis,java)