mybatis-plus lambda in eq
时间: 2023-09-24 15:09:24 浏览: 108
Mybatis-plus lambda provides a convenient and type-safe way of building SQL queries. The "eq" method in lambda is used to create an "equals" condition in the SQL query.
For example, if you have an entity called "User" with a property "name", you can use lambda to create an SQL query that selects all users with the name "John" like this:
```
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(User::getName, "John");
List<User> users = userMapper.selectList(wrapper);
```
This will generate an SQL query like this:
```
SELECT * FROM user WHERE name = 'John';
```
The "eq" method can be used with other comparison operators, such as "ne" (not equals), "gt" (greater than), "ge" (greater than or equals), "lt" (less than), and "le" (less than or equals).
阅读全文