MyBatis SQL Viewer Plugin: Features, Installation, and Usage Guide
The MyBatis SQL Viewer plugin transforms MyBatis XML into executable SQL, provides mock parameters, checks SQL standards and indexes, supports data mocking, performance testing, and offers both MyBatis and non‑MyBatis modes, all without restarting the application.
The MyBatis SQL Viewer plugin offers a suite of capabilities: converting MyBatis XML to real SQL statements, mocking parameters, checking SQL compliance and index usage, executing SQL, performing stress tests, and scanning MyBatis SQL across files or projects.
Typical development pain points—such as frequent restarts after SQL changes, cumbersome data preparation, and uncertainty about SQL performance—are addressed by the plugin, allowing developers to validate syntax, standards, and execution plans directly within the IDE.
Installation can be done via IDEA Marketplace (search "mybatis sql viewer") or manually by downloading the ZIP from the releases page and installing from disk.
Usage requires configuring a data source via the datasource button. The plugin supports two modes:
Non‑MyBatis mode: write raw SQL in the statement tab.
MyBatis mode: click the "sql" icon in mapper interfaces or XML files to generate real SQL with mock parameters, and enjoy features like mapper‑method jump, XML‑mapper navigation, and project‑wide scanning.
SQL Scanning can be performed at file level (click the "sql" icon next to a namespace) or project level (click "mybatis sql scan"). Results show namespaces, method names, generated SQL, compliance checks, index analysis, and execution plans.
SQL Validation includes syntax checking and compliance verification, with visual feedback in the UI.
SQL Execution runs the statement and displays execution information, the EXPLAIN plan, and result sets (up to 100 rows for SELECT statements).
Stress Testing is configured in the "stress" tab, allowing users to define value sources, traffic models, concurrency, duration, and then run the test, producing a report with metrics such as success rate, TP99/TP90, max/average RT, max/average TPS, concurrency, errors, and total requests.
SQL Table View parses statements to extract table names, presenting each table in a separate tab with field details, index information, and compliance checks.
Data Mocking supports various mock types (random, lexicon, database, increment, fixed, regex, none) and allows previewing and inserting large volumes of mock data, with cleanup options to remove inserted test data.
Configuration is accessible via Preferences → Tools → Mybatis Sql Viewer.
For reference, the plugin’s source code is available at https://github.com/linyimin0812/mybatis-sql-viewer .
Example SQL used in the plugin:
SELECT
state
FROM
CITY
WHERE
country_name IN (
SELECT
name
FROM
COUNTRY
WHERE
id IN (1, 2, 3)
)Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.