作者:璨然2502869273 | 来源:互联网 | 2018-04-26 02:24
mybatis初学者,如题:xml中sql语句"SELECT*FROMt_userWHERElogin_nameLIKE"%"#{value}"%""测试程序"@TestpublicvoiddeleteUser()throwsIOException{mybatis配置文件Stringresource"SqlMapConfig.xml";InputStreaminput
mybatismysqlnamespace数据库string
mybatis初学者,如题:
xml中sql语句
SELECT * FROM t_user WHERE login_name LIKE "%"#{value}"%"
测试程序
@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 users = sqlSession.selectList("test.findUserByName", "admina"); for(User user:users){ System.out.println(user); String loginName = user.getLoginName(); System.out.println(loginName); } sqlSession.close(); }
运行问题 在数据库中运行sql此项是有值的,我是根据此项查的,为什么查询成功了但是其他项都有值,就此项无值呢,求解。