mybatisplus eq方法
时间: 2023-07-17 13:06:50 浏览: 112
MyBatis Plus is an enhanced version of MyBatis, a popular Java persistence framework. It provides additional features and simplifies the data access layer development. The `eq` method in MyBatis Plus is used for creating an "equals" condition in a query.
In MyBatis Plus, you can use the `eq` method to create a query condition based on the equality of a specific column. Here's an example of how to use the `eq` method in MyBatis Plus:
```java
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
// Create a query wrapper
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
// Add an "equals" condition
queryWrapper.eq("name", "John");
// Use the query wrapper in a query
List<User> userList = userMapper.selectList(queryWrapper);
```
In the example above, we create a `QueryWrapper` object and use the `eq` method to add an "equals" condition on the `name` column with the value "John". Then, we use the query wrapper in a query to retrieve a list of users who match the condition.
Note that the `eq` method can be used with various data types, such as integers, strings, and dates. It's a convenient way to create query conditions based on equality in MyBatis Plus.
阅读全文