Databases 11 min read

MyBatis SQL Viewer Plugin: Features, Installation, and Usage Guide

The MyBatis SQL Viewer plugin transforms MyBatis XML into executable SQL, provides mock parameters, syntax and compliance checks, index analysis, performance testing, data mocking, and comprehensive UI features, enabling developers to validate, benchmark, and manage SQL without restarting the application.

Architect's Guide
Architect's Guide
Architect's Guide
MyBatis SQL Viewer Plugin: Features, Installation, and Usage Guide

The MyBatis SQL Viewer plugin offers a suite of capabilities for MyBatis developers, including converting MyBatis XML files into real SQL statements, generating mock parameters, performing SQL syntax and compliance checks, analyzing index usage, executing SQL, and conducting stress tests.

It addresses common pain points such as the need to restart applications after modifying CRUD code, difficulty in creating realistic test data for tables with relationships, and uncertainty about SQL compliance, index hit potential, performance metrics like TPS, and response times.

Installation can be performed directly from IntelliJ IDEA’s Marketplace by searching for "mybatis sql viewer" and installing, or manually by downloading the latest ZIP release and installing via the IDE’s plugin‑from‑disk option.

Usage requires configuring a data source (via the datasource button). The plugin supports two modes: a non‑MyBatis mode for raw SQL editing and a MyBatis mode that adds features such as mapper‑method parameter mocking, random/default/custom parameters, navigation between mapper interfaces and XML files, and conversion of mapper XML to real SQL using the statement tab.

SQL scanning is available at both file and project levels. Clicking the "sql" icon next to a mapper interface or namespace triggers a file‑level scan, while the "mybatis sql scan" button performs a project‑wide scan, displaying namespaces, method names, generated SQL, compliance checks, index checks, and execution plans.

When executing SQL, the Result tab shows execution information (statement, duration, row counts), the execution plan (EXPLAIN output), and the result set (first 100 rows for SELECT statements). The Stress tab allows configuring load tests with options for direct SQL usage or parameter configuration, constant or ramp‑up concurrency rates, and test duration, producing a report with metrics such as success rate, TP99/TP90, max/average RT, max/average TPS, concurrency, errors, and total requests.

The Table tab parses the SQL to extract table names (e.g., SELECT state FROM CITY WHERE country_name IN ( SELECT name FROM COUNTRY WHERE id IN (1, 2, 3) ) ) and displays each table in its own tab, showing field details, index information, compliance checks, and a data‑mocking interface. Mocking supports various types such as random values (string, name, datetime, integer, decimal, date, timestamp, time, year, city, url, email, ip, university, phone), lexicon, database look‑ups, increment, fixed, regex, and none, with preview and bulk insertion capabilities.

Configuration settings are accessible via Preferences (Settings) → Tools → Mybatis Sql Viewer . The plugin’s development referenced numerous open‑source projects and guidelines, and its source code is available at https://github.com/linyimin0812/mybatis-sql-viewer .

performance testingMyBatisDatabase ToolsSQL ViewerSQL Mocking
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

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.