SQL Table Reverse Engineering to Java Entities, Mappers, and Services: Generating Java Entities from MySQL Table Definitions

Preface

In backend projects, table structures are often first established in the database or DDL documentation, followed by the manual creation of Java entities, MyBatis-Plus annotations, and Lombok. When there are many fields, aligning type mappings and comments is prone to errors and time-consuming. Below is an introduction to the community Skill @user_faca7523/sql-to-entity on SkillHub (Page Name: sql表逆向实体类和mapper和service). It targets the reverse engineering scenario where “existing CREATE TABLE statements require Java entity classes.” An Agent parses the SQL according to Skill conventions and generates annotated entity code.

What is this

One-sentence positioning: Reverse-engineers MySQL CREATE TABLE statements into Java entity classes with MyBatis-Plus and Lombok annotations.

  • Coordinates: @user_faca7523/sql-to-entity
  • Version: 1.0.0
  • Source: community
  • Category: dev-programming
  • Publisher: user_faca7523
  • SkillHub Page: https://www.skillhub.cn/skills/user_faca7523/sql-to-entity
  • API Address: https://api.skillhub.cn/user_faca7523/sql-to-entity
  • Tags: requires_api_key=false (No API Key required)

Official Description: To be used when the user needs to generate Java entity classes from SQL CREATE TABLE statements; applicable to reverse engineering from database tables to Java entity classes. The page attributes the author as “Qiao Feng” and notes it as a self-published work.

Note: Although the Skill name contains “mapper” and “service”, the current SkillHub description only explicitly lists entity class generation capabilities (parsing table creation statements, annotated entities, type mapping, table/field comments). Whether Mapper and Service are generated concurrently should be based on the installed SKILL.md and the Agent’s actual execution. This article does not expand on capabilities not explicitly stated in the official description.

Core Features

The following are derived from the official SkillHub description, verified against the page and fetched data:

  1. Parse SQL Table Creation Statements: Uses CREATE TABLE as the input starting point.
  2. Generate Annotated Java Entity Classes: Automatically generates MyBatis-Plus and Lombok related annotations.
  3. Automatic Data Type Mapping: Maps MySQL field types to Java types (specific rules are defined by instructions within the Skill).
  4. Support Field and Table Comments: Comments from the table creation statement can be applied to entity or field descriptions.
  5. Database Scope: Explicitly supports MySQL.

Installation and Activation

The installation method is based on the SkillHub skill page: Please install @user_faca7523/sql-to-entity according to the SkillHub Installation and Priority Source Configuration.

1. Verify SkillHub CLI

First, check if skillhub is available on your machine:

command -v skillhub && skillhub --version

If not installed, you can perform a full installation (including CLI and default Skills) according to the official documentation:

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

If only the CLI is needed:

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash -s -- --cli-only

2. Install this Skill

The official requirement is to use --dir to point to the current Agent’s skills directory during installation. Otherwise, if installed in the default ./skills/, it might not be recognized.

skillhub install @user_faca7523/sql-to-entity --dir <skills directory>

You can also use search to locate it before installing:

skillhub search sql-to-entity
skillhub install @user_faca7523/sql-to-entity --dir <skills directory>

3. Skills Directories for Various Clients (Excerpt)

The common paths listed in SkillHub documentation are as follows. Replace <skills directory> above with the actual path for your Agent:

Environment skills Directory
Cursor ~/.cursor/skills/
Claude Code ~/.claude/skills/
Codex ~/.codex/skills/ or .agents/skills/ under the project
Windsurf ~/.codeium/windsurf/skills/ or .windsurf/skills/ under the project

If the Agent does not load the new Skill immediately after installation, please restart or refresh the skill list according to the instructions for your specific client.

Typical Usage

The official description page does not provide a complete conversation example, but the reproducible workflow is as follows:

  1. In an Agent with this Skill enabled (e.g., Cursor), state the goal: Generate Java entity classes based on the following MySQL CREATE TABLE statement, using MyBatis-Plus and Lombok.
  2. Paste the actual CREATE TABLE statement (including table comments, COMMENT field comments, primary keys, and common MySQL types).
  3. Let the Agent output the entity class source code according to the Skill; then compile locally and perform a field and type check against the table structure.

The input form should be consistent with the official description: SQL Table Creation Statement, rather than just a table name or connection string. If the project has package names or entity naming conventions (e.g., removing table prefixes), specify them in the conversation to facilitate generating results that fit directly into the project.

Applicable Scenarios and Notes

Who is it for

  • Developers who already have MySQL DDL and need to quickly obtain Java entity skeletons.
  • Scenarios where you want entities to uniformly carry MyBatis-Plus and Lombok annotations to reduce handwritten boilerplate code.
  • Reverse engineering “Table Structure → Code” within AI programming assistants, rather than copying and pasting results from code generator web pages every time.

Limitations and Notes

  • Database: The description only specifies MySQL; availability for CREATE TABLE statements in other dialects is not promised in the official description.
  • Capability Boundary: The description focuses on entity classes; do not assume it will generate Mapper interfaces, XML, or Service layers unless you see corresponding steps in the local Skill instructions.
  • No API Key Required: requires_api_key=false, does not depend on additional key services.
  • Community Source: Version 1.0.0, published on the community channel; for complex tables (partitions, special indexes, generated columns, etc.), manual review after generation is recommended.
  • Statistics (Fetched by SkillHub, for selection reference): Rating 100000, Downloads 764, Installs 15; subject to real-time data on the store page.

Conclusion

@user_faca7523/sql-to-entity integrates “MySQL Table Creation Statement → Java Entities with MyBatis-Plus and Lombok Annotations” into an Agent Skill, suitable for table-to-entity reverse engineering in environments like Cursor. For installation and directory configuration, see the SkillHub Installation Documentation. For skill details, see the official page: https://www.skillhub.cn/skills/user_faca7523/sql-to-entity .

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye