# mybatis/mybatis-dynamic-sql

SQL DSL (Domain Specific Language) for Kotlin and Java. Supports rendering for MyBatis or Spring JDBC Templates

Repository: https://github.com/mybatis/mybatis-dynamic-sql
Canonical: https://ross.abutalabs.com/products/mybatis-dynamic-sql
Homepage: http://www.mybatis.org/mybatis-dynamic-sql/docs/introduction.html
Language: Java
License: Apache-2.0
License Family: permissive
Topics: mybatis, mybatis3, spring-jdbctemplate, sql-generation, functional-programming, kotlin, kotlin-dsl, sql-dsl, sql-generator
Last push: 2026-08-24T16:24:52+00:00

## Health v2 (maintenance only)
Score: 79/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 42, longevity 100
- inputs: {"age_days": 3582, "days_push": 9, "days_rel": 175, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1157, forks 218 (observed 2026-08-28T04:03:48.380701+00:00)

## What it is
A typesafe SQL DSL library for Java and Kotlin that generates complete SELECT, INSERT, UPDATE, and DELETE statements with flexible WHERE clauses. It renders SQL and matching parameters for use with MyBatis3 or Spring's JDBC templates, including an idiomatic Kotlin DSL.

## Use cases
- build typesafe dynamic SQL queries in Java or Kotlin
- generate SQL statements for MyBatis mappers
- generate SQL for Spring NamedParameterJDBCTemplate
- write flexible search queries with optional criteria
- avoid string-concatenated SQL and SQL injection risks
- build complex WHERE clauses with and/or, in, like, between, and subqueries

## When to choose
- you use MyBatis or Spring JDBC and want typesafe, expressive SQL generation
- you want dynamic queries where conditions are included only when values are present
- you prefer a SQL-like DSL over string templates or full ORM abstractions
- you want idiomatic Kotlin DSL support for SQL

## When to avoid
- you need a full ORM with entity persistence, caching, and relationship management
- you don't use MyBatis or Spring JDBC as your execution runtime
- you're not on the JVM (Java 17+ for v2, Java 8 for 1.x)

## Facets
- artifact type: library
- maturity: active
- function: orm, database, serialization, developer-tools
- domain: databases, backend, web-development, developer-tools
- platform: jvm, cross-platform
- tags: sql-dsl, sql-generation, mybatis, spring-jdbc, kotlin-dsl, typesafe-sql, query-builder

## Member repositories
- mybatis/mybatis-dynamic-sql (main) score 79

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:48.380701+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:32:03.533628+00:00, confidence not recorded.
  - readme: https://github.com/mybatis/mybatis-dynamic-sql (fetched 2026-08-28T04:03:48.380701+00:00, sha 416c723ad62b)
  - homepage: http://www.mybatis.org/mybatis-dynamic-sql/docs/introduction.html (fetched 2026-08-29T12:37:05.482564+00:00, sha 082c77b25703)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/CHANGELOG.html (fetched 2026-08-29T12:37:05.491708+00:00, sha ccef1e9d869d)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/migratingV1toV2.html (fetched 2026-08-29T12:37:05.494995+00:00, sha cee911e0d789)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/quickStart.html (fetched 2026-08-29T12:37:05.501622+00:00, sha 06618239ff7b)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/exceptions.html (fetched 2026-08-29T12:37:05.503980+00:00, sha 204a9c5a5d7b)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/configuration.html (fetched 2026-08-29T12:37:05.505875+00:00, sha a243c7d64377)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/databaseObjects.html (fetched 2026-08-29T12:37:05.508136+00:00, sha 78f907ef8631)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/whereClauses.html (fetched 2026-08-29T12:37:05.510714+00:00, sha 43c4a0641764)
  - site_page: https://mybatis.org/mybatis-dynamic-sql/docs/conditions.html (fetched 2026-08-29T12:37:05.512500+00:00, sha 032e70da7738)
- Data as of 2026-08-30T08:39:29.467469+00:00.
