SmartORM is an opt-in, annotation-driven enhancement library for MyBatis-Plus applications built with Spring Boot.
It removes repetitive, fixed-shape Mapper code while preserving the MyBatis-Plus programming model and its escape hatches. Adoption is incremental: choose one Mapper and one method, keep existing paths beside it, and roll back without redesigning the application.
Note
SmartORM 2.0.x remains the verified release foundation. The current 2.1.x development line on main adds a locally installable Spring Boot Starter, but neither artifact has been published to Maven Central.
| Capability | Status | Current behavior |
|---|---|---|
| Annotation-driven CRUD | ✅ Available | @SmartSelect, @SmartInsert, @SmartUpdate, and @SmartDelete opt in per Mapper method |
| Pagination | ✅ Available | @SmartPage and PageResult; the application registers the MyBatis-Plus pagination interceptor |
DTO / Map mapping |
✅ Available | Query result inference supports entity, Map, DTO/VO, and single-result paths |
| Native SQL path | ✅ Available | Rendered SQL keeps placeholder order aligned with its compact bound-parameter list |
| Fixed JOIN declarations | ✅ Available | @SmartJoin supports explicit or convention-inferred ON; the current implementation is MPJ-based |
| Mutation safety | ✅ Available | Smart update/delete operations without an effective WHERE are blocked by default |
| Lifecycle hooks | ✅ Available | beforeSmartOperation, afterSmartOperation, and onSmartException |
| Spring Boot Starter | 🧪 Snapshot | smartorm-spring-boot-starter:2.1.0-SNAPSHOT is implemented and remotely verified; it registers its single internal Mapper while preserving application-owned MyBatis infrastructure and business Mapper scanning. It has not yet been published to Maven Central as a stable release. |
@SmartQuery is an inactive placeholder, not a supported execution entry point.
| Good fit | Consider alternatives |
|---|---|
Spring Boot applications already using MyBatis-Plus; projects with fixed CRUD, deterministic pagination, DTO / Map projections, fixed JOINs, or repeated Mapper template SQL; teams that want gradual, reversible SmartORM adoption. |
Non-Spring or reactive applications; highly dynamic or database-specific SQL; stored procedures; mature complex XML / Provider SQL with no clear maintenance pain; projects that require a fully verified multi-database dialect layer in the current version. |
Important
SmartORM does not replace MyBatis, MyBatis-Plus, BaseMapper, Wrapper, XML, Provider SQL, or MyBatis-Plus-Join. Despite its name, it is not a full ORM replacement; keep existing paths whenever they are clearer or more capable.
SmartORM keeps MyBatis-Plus entity metadata and adds an opt-in annotation to the Mapper method:
@TableName("user")
class User {
@TableId(type = IdType.AUTO)
private Long id;
@TableField("user_name")
private String userName;
private Integer status;
// getters and setters
}
public interface UserMapper extends SmartMapper<User> {
@SmartSelect(
fields = {"id", "user_name", "status"},
where = "status = #{0}",
orderBy = "id"
)
List<User> findByStatus(Integer status);
}
List<User> activeUsers = userMapper.findByStatus(1);#{0} refers to the first Java method argument. Unannotated methods continue to use normal MyBatis-Plus, Wrapper, XML, or Provider behavior. See Getting Started for the current Starter and Mapper-scan requirements.
Maven Central publication is not available yet. After cloning and validating the repository, install the current reactor into your local Maven repository:
mvn -DskipTests installThen a local Spring Boot consumer can use the development Starter coordinates:
<dependency>
<groupId>io.github.forgottenlab</groupId>
<artifactId>smartorm-spring-boot-starter</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>The Starter uses Spring Boot's AutoConfiguration.imports discovery and does not require application component scanning for SmartORM runtime components. It precisely registers its internal SmartNativeMapper; applications scan only their own Mapper packages or keep MyBatis Boot's default discovery. The Starter reuses an unambiguous application SqlSessionTemplate or SqlSessionFactory and never creates a DataSource, session infrastructure, transaction manager, or global Mapper scanner. Existing explicit/legacy Native Mapper registration is reused for migration; missing or ambiguous session infrastructure backs off conservatively.
Run the test gates separately before relying on -DskipTests; the command above only installs an already-validated local build. Applications that intentionally keep the manual integration path can depend on io.github.forgottenlab:smartorm:2.1.0-SNAPSHOT instead. The core artifact remains an ordinary library JAR. Demo classes, application.yaml, and demo SQL are excluded. MyBatis-Plus-Join remains transitive because it is exposed by SmartMapper; JSqlParser, Spring Web, and MySQL Connector/J retain the dependency boundaries documented in Compatibility.
Warning
Full-table SmartORM updates and deletes are blocked by default. Native/JOIN runtime scalar values use ordered parameter bindings, while non-JOIN @SmartSelect and the shared @SmartPage / @SmartDelete WHERE path keep runtime values in MyBatis-Plus Wrapper parameter state. SQL structure remains developer-authored metadata. An intentional full-table operation requires method-level allowFullTable = true; there is no global switch that disables this guard.
The opt-in bypasses only the missing-effective-WHERE refusal. It does not add authorization, transactions, rollback, input validation, or database protection. SmartORM does not claim universal SQL-injection prevention; keep structural fragments static and review the exact Safety boundary, including the separate current @SmartUpdate expression path.
| Layer | Scope | Evidence |
|---|---|---|
| Database-independent regressions | Non-JOIN Wrapper binding, Native SQL rendering/binding, and mutation safety | Current parameter-binding preflight: 35/35 passed |
| Starter context regressions | Internal Mapper registration, default/explicit application scans, compatibility, session selection, backoff | Current hardening: 21/21 passed without a database |
| External Starter consumer | Isolated local Maven repository, real @EnableAutoConfiguration, default business Mapper discovery, no internal-package reference |
1/1 passed online, then 1/1 offline |
| Historical MySQL double-run | Two independently created mysql:9.4.0 volumes |
2026-07-20: 46/46 twice, followed by cleanup |
| Historical random-order probe | Fixed seed 20260720 |
2026-07-20: 46/46, followed by cleanup |
| Current parameter-binding MySQL preflight | Fresh smartorm-parameter-binding Compose project |
2026-09-16: 47/47; real BoundSql mappings verified; residue 0/0/0 |
| Historical MySQL release preflight | Fresh smartorm-release-preflight Compose project |
2026-08-12: 46/46; 0 failures/errors/skips; residue 0/0/0 |
| Starter hardening MySQL regression | Fresh smartorm-starter-mapper-hardening Compose project |
2026-08-13: 46/46; cleanup residue 0/0/0 |
| Parameter-binding merge checkpoint CI | JDK 17, core 35, Starter 21, MySQL 47, package, reports, cleanup | Checkpoint SHA 093318aa: exact push/main run 35074543269 passed; Surefire artifact 10437496726; Compose container, volume, and network were removed |
Compilation, package, and artifact checks are also part of the local release preflight. The parameter-binding merge checkpoint workflow remotely verified the 35/21/47 test split at SHA 093318aa; historical runs remain evidence for earlier checkpoints. See Testing.
Annotated Mapper method
-> Aspect
-> Handler
-> Resolver / Meta
-> Wrapper Builder or SQL Renderer
-> Executor
-> MyBatis-Plus / MyBatis
SmartORM now uses a parent reactor with smartorm and the combined smartorm-spring-boot-starter child modules. The core module retains the existing public coordinates and source packages; demo sources remain inside core but are excluded from release-shaped artifacts. The optional JOIN-module split remains future major-version work. See Architecture.
| Topic | English | 简体中文 |
|---|---|---|
| Getting Started | Guide | 指南 |
| Migration | Guide | 指南 |
| Safety | Guide | 指南 |
| Testing | Evidence | 证据 |
| Architecture | Current boundaries | 当前边界 |
| Compatibility | Matrix | 矩阵 |
| Roadmap | Planned direction | 规划方向 |
| Release Checklist | Preflight | 发布预检 |
See also the Changelog.
The 2.1.x development line now contains the minimal consumer-tested Starter foundation. Configuration metadata, validation, diagnostics, API-usability work, and any deeper physical split remain separately gated roadmap items rather than delivered APIs or release promises. See the Roadmap.
Focused issues and pull requests are welcome. Please include the compatibility point, a minimal reproducer, and the smallest relevant test. Keep public API, safety, migration, and bilingual documentation implications explicit; contribution and security policies remain release follow-up work.
SmartORM is licensed under the Apache License 2.0. Current development-line verification does not imply a release, tag, Maven Central publication, or GitHub Release.