Home  >  Article  >  Database  >  mybatis+mysql selectList 出错问题

mybatis+mysql selectList 出错问题

WBOY
WBOYOriginal
2016-06-06 09:40:101772browse

mybatismysqlnamespace数据库string

mybatis初学者,如题:

xml中sql语句

<code>    <select id="findUserByName" parametertype="java.lang.String" resulttype="org.model.User">        SELECT * FROM t_user WHERE login_name LIKE "%"#{value}"%"    </select></code>

测试程序

<code>    @Test    public void deleteUser() throws IOException{        //mybatis配置文件        String resource = "SqlMapConfig.xml";        InputStream input = Resources.getResourceAsStream(resource);        //创建会话工厂        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(input);        //通过工厂得到SqlSession        SqlSession sqlSession = sqlSessionFactory.openSession();        //通过session操作数据库        //第一个参数:statement的id,等于=namespace+statementId        //第二个参赛:指定和映射文件中所匹配的parameterType类型的参数        List<user> users = sqlSession.selectList("test.findUserByName", "admina");        for(User user:users){            System.out.println(user);            String loginName = user.getLoginName();            System.out.println(loginName);        }        sqlSession.close();    }</user></code>

运行问题
图片说明
在数据库中运行sql此项是有值的,我是根据此项查的,为什么查询成功了但是其他项都有值,就此项无值呢,求解。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn