Boost MyBatis Development with MyBatis‑SQL‑Viewer: Features, Installation & Usage

This article introduces the MyBatis‑SQL‑Viewer plugin, detailing its capabilities such as converting MyBatis XML to real SQL, mock data generation, SQL compliance and index checks, execution, performance testing, and how to install and use it within IntelliJ IDEA for efficient backend development.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Boost MyBatis Development with MyBatis‑SQL‑Viewer: Features, Installation & Usage

Overview

MyBatis‑SQL‑Viewer is an IntelliJ IDEA plugin that provides MyBatis developers with the ability to convert mapper XML to executable SQL, generate mock parameters, validate SQL against coding standards, check index usage, execute queries with EXPLAIN plans, and run stress tests—all without restarting the application.

Key Features

Convert MyBatis XML to real SQL statements with automatically generated mock parameters.

Validate SQL syntax and compliance with the Alibaba Java Development Manual specifications.

Analyze index usage and detect full‑table scans.

Execute SQL directly from the IDE and view execution information, result rows (up to 100 for SELECT), and EXPLAIN plans.

Perform configurable stress testing (constant‑rate ramp‑up or fixed concurrency) with metrics such as TP99, TP90, max/average response time, max/average TPS, success rate, and error count.

Parse SQL to extract involved tables, display column metadata, and run table‑level compliance checks.

Bulk mock data generation supporting random, lexicon, database‑derived, incremental, fixed, regex, and none types; preview up to 50 rows and insert up to 100 000 rows in ~10 seconds.

Clean mock data automatically based on stored primary‑key ranges.

Installation

IDEA Marketplace :

Preferences/Settings → Plugins → Marketplace → Search "mybatis sql viewer" → Install

Manual installation : Download the latest ZIP from the GitHub releases page (e.g.,

https://github.com/linyimin0812/mybatis-sql-viewer/releases/latest

) and select

Preferences/Settings → Plugins → Install Plugin from Disk...

to install.

Configuration

Open Preferences/Settings → Tools → Mybatis Sql Viewer to configure one or more data sources (create, select, delete, test) and adjust mock‑type defaults, stress‑test parameters, and other plugin options.

Usage

Mode selection

The plugin offers two modes:

Non‑MyBatis mode : Uncheck the MyBatis checkbox and write raw SQL in the statement tab.

MyBatis mode : Check the MyBatis checkbox to enable mapper‑method parameter mocking, navigation between mapper interfaces and XML files, and automatic SQL generation from XML.

Generating SQL

In a mapper interface or XML file, click the sql icon next to a method or namespace. The plugin generates a concrete SQL statement with mock parameters and displays it in the statement tab.

SQL scanning

Two scanning scopes are supported:

File‑level : Click the sql icon beside a namespace to scan that file.

Project‑level : Use the mybatis sql scan command to scan all MyBatis files in the project. Results list namespaces, method names, generated SQL, compliance status, index warnings, and EXPLAIN plans.

SQL execution

Switch to the result tab to run the SQL from the statement tab. The output includes execution information (statement, duration, row count), the EXPLAIN plan, and result rows (up to 100 rows for SELECT).

Stress testing

Configure a stress test in the stress tab:

Choose between using the raw SQL directly or configuring parameter values.

Select a traffic model: increase in a constant rate (ramp‑up) or fixed concurrent number .

Set concurrency (number of parallel threads), ramp‑up duration (seconds), and total test duration (minutes). Keep the duration short to avoid IDE OOM.

Click the stress button to start the test. The generated report (shown in the report tab) provides metrics such as success rate, TP99/TP90, max/average response time, max/average TPS, total requests, and error count, along with charts for success rate, average RT, and TPS.

Table view

When the table tab is opened, the plugin parses the SQL, extracts each table name, and creates a separate tab per table. The left pane shows column details (name, type, nullability, default, indexes, comments). The right pane displays compliance checks for table and column naming conventions.

Data mocking

Configure mock types per column:

random : random values (string, integer, decimal, date, datetime, timestamp, time, year, city, url, email, ip, university, phone, etc.).

lexicon : custom word list.

database : values fetched from another table (specify table.field).

increment : sequential numbers.

fixed : constant value.

regex : value matching a regular expression.

none : omit the column from generated INSERT statements.

After configuring, click preview to generate a sample of 50 rows. Click mock to insert data (default 100 rows; up to 100 000 rows can be inserted quickly). Use the Clean button to delete the mock data based on the stored primary‑key range.

References

GitHub repository: https://github.com/linyimin0812/mybatis-sql-viewer JDBC performance testing – Alibaba Cloud Help Center

SQL Father – data generator project

Java MyBatis SQL Scanner (GitHub q258523454/Java-Mybatis-SQL-Scanner)

Sample SQL

SELECT
    state
FROM
    CITY
WHERE
    country_name IN (
        SELECT
            name
        FROM
            COUNTRY
        WHERE
            id IN (1, 2, 3)
    );
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend DevelopmentPerformance TestingMyBatisIDE pluginSQL MockSQL Viewer
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

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.