can be added % in the test class or % in the SQL of the configuration file in two ways:
the first way is to add:
test class:
public void findByName(){
List<User> users = userDao.findByName("王");
for (User user:users){
System.out.println(user);
}
}
profile:
<selectid="findByName"parameterType="string"resultType="com.itheima.daomain.User">
select * from user where username like '%${value}%';
</select>
the second test class adds %
test class:
public void findByName(){
List<User> users = userDao.findByName("%王%");
for (User user:users){
System.out.println(user);
}
}
profile:
<selectid="findByName"parameterType="string"resultType="com.itheima.daomain.User">
select * from user where username like #{username};
</select>
div>
Read More:
- Mybatis integrates Oracle query and reports an error in the datetime type field
- Three ways to get form data in struct2
- Compare whether two sets are the same in Java
- Four ways to get Django parameters in request
- One of the ways to solve the problem of internal server error in flash learning
- Two problems in OpenGL Programming
- Two methods of cmake in VTK program
- “No nodes available to run query” is reported when using Presto to connect to MySQL query“
- Using the pit in Git that rebase encountered two could not apply XXXX
- Three ways of single line and multi line comment in Python
- In pandas, dataframe and np.array The mutual transformation between the two
- In the SQL query statement, add the column that does not exist in the table and set the fixed value of the column
- Related configuration of mybatis project
- The jar package download of Maven project appears (could not transfer artifact. Org mybatis:mybatis )
- “Invalid month” in SQL query
- Three ways of latex supporting Chinese
- In the next two years, how do data analysts hang up highly educated engineers? be convinced!
- A convenient method to count the total number of query results in MySQL
- Failed to retrieve plugin descriptor for org.mybatis.generator :mybatis-generator
- PHP Fatal error: Call to a member function query() on a non-object in