SQL Table Entity Generator
Paste the following prompt into your AI chat to install this skill:
Please install @user_faca7523/sql-to-entity according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem to Solve
When moving from a database schema to a Java backend, developers often need to create DO, Mapper, Service, and ServiceImpl classes by hand, then add MyBatis-Plus, Lombok, and Jackson annotations. When tables contain many fields, comments, primary keys, and fixed time-column rules, manual generation can miss annotations, get naming wrong, or drop field mappings. This skill converts CREATE TABLE statements into usable Java class files, reducing boilerplate and repetitive checks, while helping teams generate base code with consistent naming.
How It Works
The skill processes SQL through a fixed pipeline:
- Parse SQL: reads CREATE TABLE statements and extracts table names, columns, comments, and constraints.
- Map types: converts INT, BIGINT, DECIMAL, VARCHAR, DATETIME, BLOB, and similar MySQL types to Java types.
- Generate entities: names entity classes with a DO suffix, such as UserDO, converts fields to camelCase, and adds @Data, @Builder, no-arg and all-arg constructor annotations.
- Generate interfaces: outputs UserMapper, UserService, and UserServiceImpl.
- Add annotations: includes @TableName, @TableId, @TableField, fill rules for create_time and update_time, and @JsonFormat for ID fields.
- Preserve naming: entity classes use the DO suffix, while Mapper and Service names remain business-oriented, making module organization easier.
Boundaries and Notes
This skill targets reverse generation from MySQL CREATE TABLE statements into MyBatis-Plus Java projects. It does not replace business SQL, complex queries, or code-style checks. Generated code should still be reviewed against project dependencies and package names; if primary-key strategy, time fields, or fill rules differ, adjust the custom template. For existing entity classes, compare fields, comments, and annotations before deciding whether to overwrite the file.
Use Cases
- Given a new MySQL CREATE TABLE statement, generate a Java DO entity and verify field comments and camelCase names.
- With CREATE TABLE SQL for orders or users, generate Mapper, Service, and ServiceImpl interface skeletons.
- Automatically add MyBatis-Plus @TableName, @TableId, @TableField, and base Lombok annotations.
- Check ID fields for @JsonFormat to avoid frontend precision loss and review time-column mappings.
Best For
- Backend engineers maintaining MyBatis-Plus projects: quickly generate DO, Mapper, and Service skeletons from SQL schemas.
- Java developers taking over legacy databases: convert CREATE TABLE comments into entity field comments and annotations.
- Engineering leads setting up base scaffolding: enforce consistent DO/Mapper/Service naming for generated base code.
- Tech leads doing code reviews: check field mappings, primary-key IDs, and time-field fill strategies for omissions.
Related Skills
A QQ bot messaging framework based on qq-botpy, covering guild, C2C, and group message flows, scheduled pushes, and troubleshooting.
Explains how to calculate N+1 severance, including service-year rounding, monthly wage base, caps, taxes, and notice pay.
Takes a name input and returns a simple hello greeting.
A BPU quantization tool for Horizon RDK S100 that handles PyTorch/ONNX calibration, stride alignment, post-processing, and board-side validation.