mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
doc: update docs
This commit is contained in:
parent
d648eb0047
commit
ba617e7c82
@ -70,12 +70,12 @@ QueryWrapper query1 = QueryWrapper.create()
|
|||||||
```sql
|
```sql
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `tb_account`
|
FROM `tb_account`
|
||||||
LEFT JOIN `tb_article` AS `a` ON `tb_account`.`id` = `a`.`account_id`
|
LEFT JOIN `tb_article` AS `a`
|
||||||
|
ON `a`.`is_delete` = 0 and `tb_account`.`id` = `a`.`account_id`
|
||||||
WHERE `tb_account`.`age` >= 10
|
WHERE `tb_account`.`age` >= 10
|
||||||
AND `tb_account`.`is_delete` = 0
|
AND `tb_account`.`is_delete` = 0
|
||||||
AND `a`.`is_delete` = 0
|
|
||||||
```
|
```
|
||||||
自动添加上 `tb_account.is_delete = 0 AND a.is_delete = 0` 条件。
|
在 `left join on` 条件自动添加:`a.is_delete = 0`,并在 where 条件添加上 `tb_account.is_delete = 0`。
|
||||||
|
|
||||||
示例 2:
|
示例 2:
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||||||
import com.mybatisflex.core.row.DbChain;
|
import com.mybatisflex.core.row.DbChain;
|
||||||
import com.mybatisflex.core.update.UpdateWrapper;
|
import com.mybatisflex.core.update.UpdateWrapper;
|
||||||
import com.mybatisflex.core.util.UpdateEntity;
|
import com.mybatisflex.core.util.UpdateEntity;
|
||||||
|
import com.mybatisflex.mapper.ArticleMapper;
|
||||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -35,11 +36,13 @@ import javax.sql.DataSource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
|
import static com.mybatisflex.test.table.AccountTableDef.ACCOUNT;
|
||||||
|
import static com.mybatisflex.test.table.ArticleTableDef.ARTICLE;
|
||||||
|
|
||||||
|
|
||||||
public class AccountTester {
|
public class AccountTester {
|
||||||
|
|
||||||
static AccountMapper accountMapper;
|
static AccountMapper accountMapper;
|
||||||
|
static ArticleMapper articleMapper;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init() {
|
public static void init() {
|
||||||
@ -53,6 +56,7 @@ public class AccountTester {
|
|||||||
.setDataSource(dataSource)
|
.setDataSource(dataSource)
|
||||||
.setLogImpl(StdOutImpl.class)
|
.setLogImpl(StdOutImpl.class)
|
||||||
.addMapper(AccountMapper.class)
|
.addMapper(AccountMapper.class)
|
||||||
|
.addMapper(ArticleMapper.class)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
//开启审计功能
|
//开启审计功能
|
||||||
@ -64,6 +68,7 @@ public class AccountTester {
|
|||||||
|
|
||||||
|
|
||||||
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||||
|
articleMapper = bootstrap.getMapper(ArticleMapper.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -101,6 +106,16 @@ public class AccountTester {
|
|||||||
System.out.println(accounts);
|
System.out.println(accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLeftJoinForLogicDelete() {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||||
|
queryWrapper.from(ARTICLE)
|
||||||
|
.leftJoin(ACCOUNT).on(ARTICLE.ACCOUNT_ID.eq(ACCOUNT.ID))
|
||||||
|
.where(ARTICLE.ID.ge(1));
|
||||||
|
List<Article> accounts = articleMapper.selectListByQuery(queryWrapper);
|
||||||
|
System.out.println(accounts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectAsToDTO() {
|
public void testSelectAsToDTO() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user