Mybatis + mysqlselectList error

Source: Internet
Author: User
Mybatis for beginners. example: SQL statement & quot; SELECT * FROMt_userWHERElogin_nameLIKE & quot; % & quot ;#{ value} & quot; % & quot; test Program & quot; @ TestpublicvoiddeleteUser () throwsIOException {mybatis configuration file Stringresource & quot; SqlMapConfig. xml & quot; InputStreaminput mybatismysqlnamespace database string

Mybatis beginners, such:

SQL statement in xml

            SELECT * FROM t_user WHERE login_name LIKE "%"#{value}"%"    

Test Procedure

@ Test public void deleteUser () throws IOException {// mybatis configuration file String resource = "SqlMapConfig. xml "; InputStream input = Resources. getResourceAsStream (resource); // Create a session factory SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder (). build (input); // Obtain SqlSession sqlSession = sqlSessionFactory through the factory. openSession (); // operate the database through the session // The first parameter: statement id, equal to = namespace + statementId // the second contestant: list of parameters that match the parameterType in the ing file
   
    
Users = sqlSession. selectList ("test. findUserByName "," admina "); for (User user: users) {System. out. println (user); String loginName = user. getLoginName (); System. out. println (loginName);} sqlSession. close ();}
   

Running problems

Run SQL in the database. This item has a value. I checked it based on this item. why is the query successful but all other items have a value? if this item has no value, solve it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.