成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

有了MyBatis-Flex ,再也不用MyBatis-Plus了

數(shù)據(jù)庫 其他數(shù)據(jù)庫
支持任意關(guān)系型數(shù)據(jù)庫,還可以通過方言持續(xù)擴(kuò)展,同時(shí)支持 多(復(fù)合)主鍵、邏輯刪除、樂觀鎖配置、數(shù)據(jù)脫敏、數(shù)據(jù)審計(jì)、 數(shù)據(jù)填充 等等功能。

一、Mybatis-Flex是什么?

Mybatis-Flex 是一個(gè)優(yōu)雅的 Mybatis 增強(qiáng)框架,它非常輕量、同時(shí)擁有極高的性能與靈活性。我們可以輕松的使用 Mybaits-Flex 鏈接任何數(shù)據(jù)庫,其內(nèi)置的 QueryWrapper^亮點(diǎn) 幫助我們極大的減少了 SQL 編寫的工作的同時(shí),減少出錯(cuò)的可能性。

總而言之,MyBatis-Flex 能夠極大地提高我們的開發(fā)效率和開發(fā)體驗(yàn),讓我們有更多的時(shí)間專注于自己的事情。

圖片圖片

  • 官網(wǎng)文檔:https://mybatis-flex.com/

二、Mybatis-Flex的有什么特點(diǎn)?

1、輕量: 除了 MyBatis,沒有任何第三方依賴輕依賴、沒有任何攔截器,其原理是通過 SqlProvider 的方式實(shí)現(xiàn)的輕實(shí)現(xiàn)。同時(shí),在執(zhí)行的過程中,沒有任何的 Sql 解析(Parse)輕運(yùn)行。這帶來了幾個(gè)好處:1、極高的性能;2、極易對代碼進(jìn)行跟蹤和調(diào)試;3、把控性更高。

2、靈活: 支持 Entity 的增刪改查、以及分頁查詢的同時(shí),Mybatis-Flex 提供了 Db + Row^靈活 工具,可以無需實(shí)體類對數(shù)據(jù)庫進(jìn)行增刪改查以及分頁查詢。與此同時(shí),Mybatis-Flex 內(nèi)置的 QueryWrapper^靈活 可以輕易的幫助我們實(shí)現(xiàn) 多表查詢、鏈接查詢、子查詢 等等常見的 SQL 場景。

3、強(qiáng)大: 支持任意關(guān)系型數(shù)據(jù)庫,還可以通過方言持續(xù)擴(kuò)展,同時(shí)支持 多(復(fù)合)主鍵、邏輯刪除、樂觀鎖配置、數(shù)據(jù)脫敏、數(shù)據(jù)審計(jì)、 數(shù)據(jù)填充 等等功能。

三、Mybatis-Flex和同類框架對比

1)功能對比:

功能或特點(diǎn)

MyBatis-Flex

MyBatis-Plus

Fluent-MyBatis

對 entity 的基本增刪改查

?

?

?

分頁查詢

?

?

?

分頁查詢之總量緩存

?

?

?

分頁查詢無 SQL 解析設(shè)計(jì)(更輕量,及更高性能)

?

?

?

多表查詢:from 多張表

?

?

?

多表查詢:left join、inner join 等等

?

?

?

多表查詢:union,union all

?

?

?

單主鍵配置

?

?

?

多種 id 生成策略

?

?

?

支持多主鍵、復(fù)合主鍵

?

?

?

字段的 typeHandler 配置

?

?

?

除了 MyBatis,無其他第三方依賴(更輕量)

?

?

?

QueryWrapper 是否支持在微服務(wù)項(xiàng)目下進(jìn)行 RPC 傳輸

?

?

未知

邏輯刪除

?

?

?

樂觀鎖

?

?

?

SQL 審計(jì)

?

?

?

數(shù)據(jù)填充

?

?? (收費(fèi))

?

數(shù)據(jù)脫敏

?

?? (收費(fèi))

?

字段權(quán)限

?

?? (收費(fèi))

?

字段加密

?

?? (收費(fèi))

?

字典回寫

?

?? (收費(fèi))

?

Db + Row

?

?

?

Entity 監(jiān)聽

?

?

?

多數(shù)據(jù)源支持

?

借助其他框架或收費(fèi)

?

多數(shù)據(jù)源是否支持 Spring 的事務(wù)管理,比如 @Transactional 和 TransactionTemplate 等

?

?

?

多數(shù)據(jù)源是否支持 "非Spring" 項(xiàng)目

?

?

?

多租戶

?

?

?

動態(tài)表名

?

?

?

動態(tài) Schema

?

?

?

2)性能對比:

這里直接貼測試結(jié)果:

  • MyBatis-Flex 的查詢單條數(shù)據(jù)的速度,大概是 MyBatis-Plus 的 5 ~ 10+ 倍。
  • MyBatis-Flex 的查詢 10 條數(shù)據(jù)的速度,大概是 MyBatis-Plus 的 5~10 倍左右。
  • Mybatis-Flex 的分頁查詢速度,大概是 Mybatis-Plus 的 5~10 倍左右。
  • Mybatis-Flex 的數(shù)據(jù)更新速度,大概是 Mybatis-Plus 的 5~10+ 倍。

具體性能對比測試,移步:

  • https://mybatis-flex.com/zh/intro/benchmark.html

四、Mybatis-Flex支持的數(shù)據(jù)庫類型

MyBatis-Flex 支持的數(shù)據(jù)庫類型,如下表格所示,我們還可以通過自定義方言的方式,持續(xù)添加更多的數(shù)據(jù)庫支持。

數(shù)據(jù)庫

描述

mysql

MySQL 數(shù)據(jù)庫

mariadb

MariaDB 數(shù)據(jù)庫

oracle

Oracle11g 及以下數(shù)據(jù)庫

oracle12c

Oracle12c 及以上數(shù)據(jù)庫

db2

DB2 數(shù)據(jù)庫

hsql

HSQL 數(shù)據(jù)庫

sqlite

SQLite 數(shù)據(jù)庫

postgresql

PostgreSQL 數(shù)據(jù)庫

sqlserver2005

SQLServer2005 數(shù)據(jù)庫

sqlserver

SQLServer 數(shù)據(jù)庫

dm

達(dá)夢數(shù)據(jù)庫

xugu

虛谷數(shù)據(jù)庫

kingbasees

人大金倉數(shù)據(jù)庫

phoenix

Phoenix HBase 數(shù)據(jù)庫

gauss

Gauss 數(shù)據(jù)庫

clickhouse

ClickHouse 數(shù)據(jù)庫

gbase

南大通用(華庫)數(shù)據(jù)庫

gbase-8s

南大通用數(shù)據(jù)庫 GBase 8s

oscar

神通數(shù)據(jù)庫

sybase

Sybase ASE 數(shù)據(jù)庫

OceanBase

OceanBase 數(shù)據(jù)庫

Firebird

Firebird 數(shù)據(jù)庫

derby

Derby 數(shù)據(jù)庫

highgo

瀚高數(shù)據(jù)庫

cubrid

CUBRID 數(shù)據(jù)庫

goldilocks

GOLDILOCKS 數(shù)據(jù)庫

csiidb

CSIIDB 數(shù)據(jù)庫

hana

SAP_HANA 數(shù)據(jù)庫

impala

Impala 數(shù)據(jù)庫

vertica

Vertica 數(shù)據(jù)庫

xcloud

行云數(shù)據(jù)庫

redshift

亞馬遜 redshift 數(shù)據(jù)庫

openGauss

華為 openGauss 數(shù)據(jù)庫

TDengine

TDengine 數(shù)據(jù)庫

informix

Informix 數(shù)據(jù)庫

greenplum

Greenplum 數(shù)據(jù)庫

uxdb

優(yōu)炫數(shù)據(jù)庫

快速開始

第 1 步:創(chuàng)建數(shù)據(jù)庫表

CREATE TABLE IF NOT EXISTS `tb_account`
(
    `id`        INTEGER PRIMARY KEY auto_increment,
    `user_name` VARCHAR(100),
    `age`       INTEGER,
    `birthday`  DATETIME
);

INSERT INTO tb_account(id, user_name, age, birthday)
VALUES (1, '張三', 18, '2020-01-11'),
       (2, '李四', 19, '2021-03-21');

第 2 步:創(chuàng)建 Spring Boot 項(xiàng)目,并添加 Maven 依賴

TIP:可以使用 Spring Initializer 快速初始化一個(gè) Spring Boot 工程。

需要添加的 Maven 主要依賴示例:

<dependencies>
    <dependency>
        <groupId>com.mybatis-flex</groupId>
        <artifactId>mybatis-flex-spring-boot-starter</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
    </dependency>
    <!-- for test only -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

第 3 步:對 Spring Boot 項(xiàng)目進(jìn)行配置

在 application.yml 中配置數(shù)據(jù)源:

# DataSource Config
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/flex_test
    username: root
    password: 12345678

在 Spring Boot 啟動類中添加 @MapperScan 注解,掃描 Mapper 文件夾:

@SpringBootApplication
@MapperScan("com.mybatisflex.test.mapper")
public class MybatisFlexTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(MybatisFlexTestApplication.class, args);
    }

}

第 4 步:編寫實(shí)體類和 Mapper 接口

這里使用了 Lombok 來簡化代碼。

@Data
@Table("tb_account")
public class Account {

    @Id(keyType = KeyType.Auto)
    private Long id;
    private String userName;
    private Integer age;
    private Date birthday;

}
  • 使用 @Table("tb_account") 設(shè)置實(shí)體類與表名的映射關(guān)系
  • 使用 @Id(keyType = KeyType.Auto) 標(biāo)識主鍵為自增

Mapper 接口繼承 BaseMapper 接口:

public interface AccountMapper extends BaseMapper<Account> {

}

這部分也可以使用 MyBatis-Flex 的代碼生成器來生,功能非常強(qiáng)大的。詳情進(jìn)入:

  • https://mybatis-flex.com/zh/others/codegen.html

第 5 步:開始使用

添加測試類,進(jìn)行功能測試:

import static com.mybatisflex.test.entity.table.AccountTableDef.ACCOUNT;

@SpringBootTest
class MybatisFlexTestApplicationTests {

    @Autowired
    private AccountMapper accountMapper;

    @Test
    void contextLoads() {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select()
                .where(ACCOUNT.AGE.eq(18));
        Account account = accountMapper.selectOneByQuery(queryWrapper);
        System.out.println(account);
    }

}

控制臺輸出:

Account(id=1, userName=張三, age=18, birthday=Sat Jan 11 00:00:00 CST 2020)

以上的 示例 中, ACCOUNT 為 MyBatis-Flex 通過 APT 自動生成,只需通過靜態(tài)導(dǎo)入即可,無需手動編碼。

整體來講,這個(gè)框架是Mybatis的增強(qiáng)版,幾乎集成了mybatis plus、jooq、fluent mybatis的所有優(yōu)點(diǎn),大家可以探索一番,官方網(wǎng)站:

https://mybatis-flex.com/

責(zé)任編輯:武曉燕 來源: java知路
相關(guān)推薦

2022-06-01 10:09:39

Linux網(wǎng)絡(luò)延遲

2021-12-21 09:05:46

命令Linux敲錯(cuò)

2023-10-31 08:01:48

Mybatis參數(shù)jdbcurl?

2024-12-20 16:49:15

MyBatis開發(fā)代碼

2019-09-04 10:00:07

手機(jī)人臉識別

2024-04-15 00:08:00

MySQLInnoDB數(shù)據(jù)庫

2015-05-29 09:01:48

2020-06-15 08:03:17

大文件OOM內(nèi)存

2016-08-09 16:17:37

高德地圖TFBOYS大數(shù)據(jù)

2022-07-15 13:58:46

工具MyBatissql

2018-10-11 15:51:32

ChromeGoogle瀏覽器

2023-11-27 17:11:02

數(shù)據(jù)庫oracle

2020-12-18 08:23:16

安卓手機(jī)系統(tǒng)谷歌

2024-01-26 07:00:11

Python工具無向圖

2021-08-13 22:38:36

大數(shù)據(jù)互聯(lián)網(wǎng)技術(shù)

2025-04-25 10:00:00

2020-01-21 21:15:16

WiFi網(wǎng)絡(luò)WiFi6

2015-10-22 10:38:43

Wi-Fi燃?xì)鈭?bào)警器

2021-08-12 11:05:07

C++語言內(nèi)存泄露

2022-04-14 10:22:30

NginxLinux
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 91xx在线观看| 日韩成人精品一区 | 五月综合久久 | 日韩中文字幕视频在线观看 | 久久视频精品 | 日韩精品一区二区久久 | 免费一级大片 | 久久福利电影 | 久久久黑人 | 日韩在线视频一区 | xx视频在线观看 | 欧美精品二区 | 丁香六月伊人 | 天天操天天射综合 | 2020天天操 | 日韩精品无码一区二区三区 | 成人av影院 | 欧美乱大交xxxxx另类电影 | 久久久久久一区 | 久久久久久天堂 | 99在线免费视频 | 久久成人精品一区二区三区 | 天天草草草 | 亚洲国产网址 | 久久精品在线 | 中文字幕日韩欧美一区二区三区 | 91视频在线观看 | 国内精品视频在线 | 亚洲一区二区三区视频 | 狠狠操狠狠干 | 国产成人高清视频 | 91九色网站 | 欧美日韩综合一区 | 一区二区伦理电影 | 视频一区二区三区四区五区 | 男女下面一进一出网站 | 国产精品中文字幕在线观看 | 日韩免费看视频 | 国产精品久久久久久久久久久久久久 | 欧美美乳 | 成人av电影网 |