Boost CRUD Development Speed 100× with This Open‑Source Code Generator

Manually creating entity classes, CRUD interfaces and SQL for dozens of tables can consume dozens of hours, so the author built an open‑source tool that automatically generates the full backend stack—from table definition to Java models, MyBatis mappers, services and controllers—dramatically accelerating development.

Architect's Guide
Architect's Guide
Architect's Guide
Boost CRUD Development Speed 100× with This Open‑Source Code Generator

Problem

Creating a new database table typically requires manually writing an entity class, DAO interface, service implementation, controller and CRUD SQL. For a project with more than 20 tables the author estimated about two hours per table, i.e., >40 hours of repetitive work.

Tool

A web tool (hosted at https://utilsbox.cn/) generates the full business layer from a table definition. The source code is open‑source on GitHub: https://github.com/GooseCoding/utilsbox.

Demo workflow

Enter the table name (e.g. goods_order) and its Chinese description ( 商品订单).

Add field definitions (name, type, comment, primary‑key flag) using the same UI as typical DB clients.

Click “One‑click generate code”.

The tool outputs:

CREATE TABLE SQL.

INSERT/UPDATE/SELECT SQL statements.

Java entity class.

MyBatis DAO interface.

Service interface and implementation.

Controller class.

Model‑converter class.

Generated entity example

/**
 * 商品订单Model模型
 * Created by 创建人 on 2023-02-05 17:12:32.
 */
public class GoodsOrderModel extends ToString {
}

Code‑generation principle

The engine uses user‑defined templates containing placeholders (dynamic parameters) such as $table_name$, $table_desc$, $table_name_hump_A$, etc. During rendering the placeholders are replaced with values derived from the table definition (raw name, camel‑case variants, field types, timestamps, etc.) and the resulting text is written to source files.

Template example

/**
 * $table_desc$Model模型
 * Created by 创建人 on $current_time$.
 */
public class $table_name_hump_A$Model extends ToString {
}

With table_name = goods_order and table_desc = 商品订单 the generated class becomes the snippet shown above.

Built‑in templates

The default set includes templates for CREATE TABLE SQL, entity class, DAO interface (MyBatis), service implementation, controller, and model converters. Each template references a collection of dynamic parameters (e.g. $create_table_field_list$, $member_param_list$, $get_set_method_list$) whose meanings are documented in the tool.

Dynamic parameters reference

$table_name$

– raw table name. $table_name_hump$ – camel‑case, first letter lower case (e.g. goodsOrder). $table_name_hump_A$ – camel‑case, first letter upper case (e.g. GoodsOrder). $field_name$, $field_name_hump$, $field_name_hump_A$ – field name variants. $field_type_java$, $field_type_db$ – Java and DB type mappings. $primary_key$, $primary_key_hump$, $primary_key_hump_A$, $primary_key_type_java$ – primary‑key information. $create_table_field_list$ – column definitions for CREATE TABLE. $insert_field_name_list$, $insert_field_value_list$ – column names and MyBatis placeholders for INSERT. $update_field_list$ – “col = #{field}” pairs for UPDATE. $select_field_list$ – column list for SELECT. $where_field_list$ – conditional fragments generated from non‑null request parameters. $member_param_list$ – generated private member declarations. $get_set_method_list$ – generated getter/setter methods. $converter_source_to_target_params_list$ – field‑by‑field copy statements for model conversion. $biz_check_required_params$ – generated assertions for required fields. $current_time$ – timestamp at generation time (format yyyy‑MM‑dd HH:mm:ss).

Template configuration

Because project structures differ, the tool provides a “code template configuration” dialog. Users can add, delete or edit templates for each layer (entity, DAO, service, controller, converter) and export/import the configuration for sharing.

Existing table support

The tool can parse a CREATE TABLE statement pasted into a text box, extract the table name, fields and comments, then generate the same set of business code after the user supplies the Chinese description.

Open‑source

Source code, issue tracker and releases are available at the GitHub repository https://github.com/GooseCoding/utilsbox.

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.

backendJavacode generationautomationMyBatisCRUD
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

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.