Skip to content



Doma 2 is a database access framework for Java 8+. Doma has various strengths:

  • Verifies and generates source code at compile time using annotation processing.
  • Provides type-safe Criteria API.
  • Supports Kotlin.
  • Uses SQL templates, called "two-way SQL".
  • Has no dependence on other libraries.

Build Status javadoc project chat Twitter


Type-safe Criteria API

Written in Java 8:

Entityql entityql = new Entityql(config);
Employee_ e = new Employee_();
Department_ d = new Department_();

List<Employee> list = entityql
    .innerJoin(d, on -> on.eq(e.departmentId, d.departmentId))
    .where(c -> c.eq(d.departmentName, "SALES"))
    .associate(e, d, (employee, department) -> {

Written in Kotlin:

val entityql = KEntityql(config)
val e = Employee_()
val d = Department_()

val list = entityql
    .innerJoin(d) { eq(e.departmentId, d.departmentId) }
    .where { eq(d.departmentName, "SALES") }
    .associate(e, d) { employee, department ->
        employee.department = department
        department.employeeList += employee

See Criteria API for more information.

SQL templates

Written in Java 15 or above:

public interface EmployeeDao {

    select * from EMPLOYEE where
    /*%if salary != null*/
      SALARY >= /*salary*/9999
  List<Employee> selectBySalary(BigDecimal salary);

See SQL templates for more information.

More Examples

Try Getting started and simple-examples.



For Java projects:

dependencies {

For Kotlin projects, use doma-kotlin instead of doma-core and use kapt in place of annotationProcessor:

dependencies {


We recommend using Gradle, but if you want to use Maven, see below.

For Java projects:

                <source>1.8</source> <!-- depending on your project -->
                <target>1.8</target> <!-- depending on your project -->
                    <!-- if you are using a Maven project in Eclipse, this argument is required -->

For Kotlin projects, see Kotlin document.



Related projects

Major versions

Status and Repository

Version Status Repository Branch
Doma 1 stable master
Doma 2 stable master

Compatibility matrix

Doma 1 Doma 2
Java 6 v
Java 7 v
Java 8 v v
Java 9 v
Java 10 v
Java 11 v
Java 12 v
Java 13 v
Java 14 v
Java 15 v
Java 16 v
Java 17 v
Java 18 v
Java 19 v
Java 20 v
Java 21 v
Java 22 v

Backers & Sponsors

If you use Doma in your project or enterprise and would like to support ongoing development, please consider becoming a backer or a sponsor. Sponsor logos will show up here with a link to your website.

[Become a backer or a sponsor]