mybatis-flex
MyBatis-Flex is a lightweight Java ORM enhancement framework built on MyBatis that provides fluent query building, automatic CRUD operations, and multi-database support. It requires no external dependencies beyond MyBatis and supports Java 8 through 25.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | mybatis-flex/mybatis-flex |
| Owner | mybatis-flex |
| Primary language | Java |
| License | Apache-2.0 — OSI-approved |
| Stars | 2.6k |
| Forks | 255 |
| Open issues | 287 |
| Latest release | v1.11.8 (2026-07-01) |
| Last updated | 2026-07-01 |
| Source | https://github.com/mybatis-flex/mybatis-flex |
What mybatis-flex is
MyBatis-Flex extends MyBatis with a type-safe QueryWrapper API for dynamic SQL construction, BaseMapper for entity CRUD, row mapping without entities, dialect-based multi-database support, and composite key handling. It includes JSpecify nullness annotations for IDE support and works with Spring Boot 2.x/3.x/4.x and Solon 2.x frameworks.
Get the mybatis-flex source
Clone the repository and explore it locally.
git clone https://github.com/mybatis-flex/mybatis-flex.gitcd mybatis-flex# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Requires entity class definition with @Table/@Id annotations; row mapping is optional but entity-first design is primary pattern.
- QueryWrapper and generated column references (ACCOUNT, ARTICLE constants) depend on code generation or reflection—verify tooling support in your IDE and build pipeline.
- No built-in caching, audit, or soft-delete support; implement at application or interceptor level if needed.
- JSpecify annotations present but no compile-time checker included; nullness validation relies on IDE plugins or external tools.
- Multi-database dialect support is extensible but requires custom implementation for unsupported vendors; test SQL generation thoroughly per target DB.
When to avoid it — and what to weigh
- Non-relational or document-oriented database focus — MyBatis-Flex is RDBMS-only; it will not provide value for NoSQL, graph, or document stores. Consider alternatives if your workload is MongoDB, Cassandra, or similar.
- Complex, hand-optimized SQL with stored procedures — Environments requiring fine-grained control over every query execution or heavy use of database-native logic are better served by direct JDBC or lower-level MyBatis mapping.
- Zero-dependency or minimal footprint constraints — While lightweight for an ORM, MyBatis-Flex adds runtime and JAR size; projects with strict embedded or edge constraints may prefer raw JDBC.
- Mature, battle-tested adoption requirement — Project created February 2023; limited production deployment history compared to Hibernate, JPA, or older MyBatis patterns. Requires internal vetting and risk tolerance for newer frameworks.
License & commercial use
Apache License 2.0 (Apache-2.0) is a permissive, OSI-approved open-source license. Allows commercial use, modification, and distribution with source code notice and license inclusion required.
Apache-2.0 explicitly permits commercial use, proprietary modification, and distribution. No restrictions on closed-source applications. Requires retention of license and copyright notices in source and/or documentation. No commercial support model or warranty noted in repository; rely on community or contract custom support.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
QueryWrapper uses parameterized queries (evident from ? placeholders in SQL examples), reducing SQL injection risk. No details on encrypted credential handling, audit logging, or rate limiting. Standard JDBC security practices apply: validate input at application layer, use connection pooling secrets management (HikariDataSource), and apply least-privilege DB user accounts. Conduct threat modeling for your specific threat profile; no formal security audit or CVE history visible.
Alternatives to consider
Hibernate / JPA
Industry-standard, mature ORM with richer ecosystem, caching, lazy loading, and vendor support. Better for complex domain models; steeper learning curve and higher footprint.
MyBatis (plain)
Lower-level predecessor of MyBatis-Flex; more explicit SQL control, minimal abstractions. Better for teams needing raw SQL without code generation; requires manual CRUD and query building.
Spring Data JPA
Spring-first abstraction over JPA with declarative query methods and built-in pagination/sorting. Easier for Spring developers; vendor lock-in to Hibernate and less control over SQL generation.
Build on mybatis-flex with DEV.co software developers
MyBatis-Flex offers rapid CRUD scaffolding and fluent query building for Spring Boot and standalone Java apps. Evaluate it for your next microservice or enterprise project—or contact Devco for custom integration and performance optimization.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
mybatis-flex FAQ
Does MyBatis-Flex require Spring?
How does QueryWrapper prevent SQL injection?
Can I use MyBatis-Flex without entity classes?
What Java versions are supported?
Custom software development services
Adopting mybatis-flex is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.
Ready to streamline your Java data layer?
MyBatis-Flex offers rapid CRUD scaffolding and fluent query building for Spring Boot and standalone Java apps. Evaluate it for your next microservice or enterprise project—or contact Devco for custom integration and performance optimization.