DEV.co
Open-Source Databases · mybatis-flex

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.

Source: GitHub — github.com/mybatis-flex/mybatis-flex
2.6k
GitHub stars
255
Forks
Java
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorymybatis-flex/mybatis-flex
Ownermybatis-flex
Primary languageJava
LicenseApache-2.0 — OSI-approved
Stars2.6k
Forks255
Open issues287
Latest releasev1.11.8 (2026-07-01)
Last updated2026-07-01
Sourcehttps://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.

Quickstart

Get the mybatis-flex source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/mybatis-flex/mybatis-flex.gitcd mybatis-flex# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Data-heavy Java applications needing type-safe query building

Teams building microservices or enterprise applications requiring fluent, IDE-aware query construction without raw SQL or verbose ORM boilerplate. QueryWrapper provides compile-time safety and autocomplete.

Multi-database deployments with flexible dialect support

Applications supporting MySQL, PostgreSQL, Oracle, Informix, or other RDBMS where custom dialect plugins allow tailored SQL generation per target database without code duplication.

Rapid CRUD scaffolding with minimal configuration

Greenfield projects or internal tools where quick entity-to-database binding with automatic pagination, filtering, and basic SQL generation reduces boilerplate and accelerates time-to-value.

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.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

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.

Software development agency

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.co

Related 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?
No. Hello-world example demonstrates standalone use with HikariDataSource and MybatisFlexBootstrap. Spring Boot is optional and provides auto-configuration convenience, but core framework is framework-agnostic.
How does QueryWrapper prevent SQL injection?
QueryWrapper generates parameterized SQL with ? placeholders; values are passed as bind parameters to JDBC, not string-concatenated. Standard JDBC security model applies.
Can I use MyBatis-Flex without entity classes?
Yes, row mapping is supported. README states 'you can add, delete, modify and query the database without entity classes', though entity-first CRUD is the primary pattern.
What Java versions are supported?
Java 8, 11, 17, 21, and 25 are explicitly listed in README badges. Compatibility for JDK 8+ is core. Verify LTS adoption aligns with your runtime.

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.