Databases 12 min read

MyBatis-Mate: Enterprise-Level Features for Sharding, Encryption, Data Permissions and Automatic DDL Management

mybatis-mate is an enterprise‑level MyBatis‑Plus extension that offers sharding, data auditing, dictionary binding, field encryption, sensitive‑word filtering, automatic DDL maintenance, multi‑datasource switching, performance logging, and data‑scope control, providing a comprehensive solution for agile and secure database operations.

Top Architecture Tech Stack
Top Architecture Tech Stack
Top Architecture Tech Stack
MyBatis-Mate: Enterprise-Level Features for Sharding, Encryption, Data Permissions and Automatic DDL Management

mybatis-mate is an enterprise‑level module for MyBatis‑Plus that provides features such as sharding, data auditing, AC‑algorithm sensitive‑word filtering, field encryption, dictionary binding, data permissions, automatic DDL generation and SQL maintenance, aiming to handle data more agilely and elegantly.

Main functions include dictionary binding, field encryption, data desensitization, dynamic table structure maintenance, audit logging, data‑scope control, multi‑datasource read/write separation, health‑check, and distributed transaction logging.

Dependency import (Maven):

com.baomidou
mybatis-mate-starter
1.0.8

Annotation @FieldDict binds a dictionary value to a target field, while @FieldEncrypt encrypts a column and automatically decrypts it on query. @FieldSensitive applies built‑in or custom desensitization strategies.

DDL auto‑maintenance supports MySQL and PostgreSQL; custom DDL scripts can be executed dynamically or via multiple data sources.

Dynamic multi‑datasource switching is achieved with @Sharding on mapper methods, and custom sharding strategies can be implemented by extending RandomShardingStrategy .

The provided PerformanceInterceptor logs SQL execution time, optionally formats SQL, writes to log files, and can abort queries that exceed a configured maximum duration.

Data‑scope control is demonstrated with @DataScope and @DataColumn annotations, allowing automatic injection of WHERE clauses based on user permissions.

Configuration examples for sharding, health checks, and datasource groups are shown in YAML format.

For more examples, see the official repository: https://gitee.com/baomidou/mybatis-mate-examples .

JavadatabaseShardingMyBatisEncryptionData Permission
Top Architecture Tech Stack
Written by

Top Architecture Tech Stack

Sharing Java and Python tech insights, with occasional practical development tool tips.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.