v1.0.0 beta2 release

This commit is contained in:
开源海哥 2023-03-02 18:35:12 +08:00
parent e51d0d49bc
commit de950913b1
2 changed files with 33 additions and 22 deletions

View File

@ -1,2 +1,13 @@
mybatis-flex v1.0.0-beta.2 20230303:
优化当只查询一张表时SQL生成的字段不添加表前缀
优化:完善对 @Column(onUpdateValue=xxx,onInsertValue=xxx) 的支持
优化:完善对 @Column(version = true) 的支持
优化:重命名 BaseMapper 的 insertBatchWithFirstEntityColumns 为 insertBatch
优化:为逻辑删除的默认值功能添加常量
修复createDialectByDbType 方法中pg库的 KeywordWrap 错误
文档:优化文档
mybatis-flex v1.0.0-beta.1: mybatis-flex v1.0.0-beta.1:
init mybatis-flex init mybatis-flex

View File

@ -139,9 +139,9 @@ class HelloWorld {
// 执行 SQL // 执行 SQL
// ELECT * FROM `tb_account` // ELECT * FROM `tb_account`
// WHERE `tb_account`.`id` >= 100 // WHERE `id` >= 100
// AND (`tb_account`.`user_name` LIKE '%张%' OR `tb_account`.`user_name` LIKE '%李%' ) // AND (`user_name` LIKE '%张%' OR `user_name` LIKE '%李%' )
// ORDER BY `tb_account`.`id` DESC // ORDER BY `id` DESC
// LIMIT 40,10 // LIMIT 40,10
Page<Account> accounts = MybatisFlexBootstrap.getInstance() Page<Account> accounts = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper -> .execute(AccountMapper.class, mapper ->
@ -171,7 +171,7 @@ QueryWrapper query=new QueryWrapper();
query.select(ACCOUNT.ID,ACCOUNT.USER_NAME).from(ACCOUNT) query.select(ACCOUNT.ID,ACCOUNT.USER_NAME).from(ACCOUNT)
// SQL: // SQL:
// SELECT tb_account.id, tb_account.user_name // SELECT id, user_name
// FROM tb_account // FROM tb_account
``` ```
@ -180,8 +180,7 @@ QueryWrapper query=new QueryWrapper();
query.select(ACCOUNT.ALL_COLUMNS).from(ACCOUNT) query.select(ACCOUNT.ALL_COLUMNS).from(ACCOUNT)
// SQL: // SQL:
// SELECT tb_account.id, tb_account.user_name, tb_account.birthday, // SELECT id, user_name, birthday, sex, is_normal
// tb_account.sex, tb_account.is_normal
// FROM tb_account // FROM tb_account
``` ```
@ -197,9 +196,9 @@ query.select(ACCOUNT.ALL_COLUMNS).from(ACCOUNT)
).from(ACCOUNT); ).from(ACCOUNT);
// SQL: // SQL:
// SELECT tb_account.id, tb_account.user_name, // SELECT id, user_name,
// MAX(tb_account.birthday), // MAX(birthday),
// AVG(tb_account.sex) AS sex_avg // AVG(sex) AS sex_avg
// FROM tb_account // FROM tb_account
``` ```
@ -214,8 +213,8 @@ QueryWrapper queryWrapper=QueryWrapper.create()
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// WHERE tb_account.id >= ? // WHERE id >= ?
// AND tb_account.user_name LIKE ? // AND user_name LIKE ?
``` ```
### exists, not exists ### exists, not exists
@ -233,9 +232,9 @@ QueryWrapper queryWrapper=QueryWrapper.create()
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// WHERE tb_account.id >= ? // WHERE id >= ?
// AND EXIST ( // AND EXIST (
// SELECT 1 FROM tb_article WHERE tb_article.id >= ? // SELECT 1 FROM tb_article WHERE id >= ?
// ) // )
``` ```
@ -251,9 +250,9 @@ QueryWrapper queryWrapper=QueryWrapper.create()
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// WHERE tb_account.id >= ? // WHERE id >= ?
// AND (tb_account.sex = ? OR tb_account.sex = ? ) // AND (sex = ? OR sex = ? )
// OR (tb_account.age IN (?,?,?) OR tb_account.user_name LIKE ? ) // OR (age IN (?,?,?) OR user_name LIKE ? )
``` ```
### group by ### group by
@ -266,7 +265,7 @@ QueryWrapper queryWrapper=QueryWrapper.create()
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// GROUP BY tb_account.user_name // GROUP BY user_name
``` ```
### having ### having
@ -280,8 +279,8 @@ QueryWrapper queryWrapper=QueryWrapper.create()
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// GROUP BY tb_account.user_name // GROUP BY user_name
// HAVING tb_account.age BETWEEN ? AND ? // HAVING age BETWEEN ? AND ?
``` ```
### join ### join
@ -290,12 +289,13 @@ QueryWrapper queryWrapper = QueryWrapper.create()
.select() .select()
.from(ACCOUNT) .from(ACCOUNT)
.leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID)) .leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
.innerJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
.where(ACCOUNT.AGE.ge(10)); .where(ACCOUNT.AGE.ge(10));
// SQL: // SQL:
// SELECT * FROM tb_account // SELECT * FROM tb_account
// LEFT JOIN tb_article // LEFT JOIN tb_article ON tb_account.id = tb_article.account_id
// ON tb_account.id = tb_article.account_id // INNER JOIN tb_article ON tb_account.id = tb_article.account_id
// WHERE tb_account.age >= ? // WHERE tb_account.age >= ?
``` ```
@ -352,7 +352,7 @@ Page<Row> rowPage = Db.paginate("tb_account",3,10,query);
## Entity 部分字段更新 ## Entity 部分字段更新
相比市面上的其他框架,这部分的功能应该也算是 MyBatis-Flex 的亮点之一(独创 。在 BaseMapper 中Mybatis-Flex 提供了如下的方法: 相比市面上的其他框架,这部分的功能应该也算是 MyBatis-Flex 的亮点之一。在 BaseMapper 中Mybatis-Flex 提供了如下的方法:
```java ```java
update(T entity, boolean ignoreNulls) update(T entity, boolean ignoreNulls)