Home

Awesome

Doma

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

Build Status javadoc project chat Twitter

Examples

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
    .from(e)
    .innerJoin(d, on -> on.eq(e.departmentId, d.departmentId))
    .where(c -> c.eq(d.departmentName, "SALES"))
    .associate(e, d, (employee, department) -> {
        employee.setDepartment(department);
        department.getEmployeeList().add(employee);
    })
    .fetch();

Written in Kotlin:

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

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

See Criteria API for more information.

SQL templates

Written in Java 15 or above:

@Dao
public interface EmployeeDao {

  @Sql(
    """
    select * from EMPLOYEE where
    /*%if salary != null*/
      SALARY >= /*salary*/9999
    /*%end*/
    """)
  @Select
  List<Employee> selectBySalary(BigDecimal salary);
}

See SQL templates for more information.

More Examples

Try Getting started and simple-examples.

Installing

Gradle

For Java projects:

dependencies {
    implementation("org.seasar.doma:doma-core:2.60.1")
    annotationProcessor("org.seasar.doma:doma-processor:2.60.1")
}

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

dependencies {
    implementation("org.seasar.doma:doma-kotlin:2.60.1")
    kapt("org.seasar.doma:doma-processor:2.60.1")
}

Maven

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

For Java projects:

...
<properties>
    <doma.version>2.60.1</doma.version>
</properties>
...
<dependencies>
    <dependency>
        <groupId>org.seasar.doma</groupId>
        <artifactId>doma-core</artifactId>
        <version>${doma.version}</version>
    </dependency>
</dependencies>
...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source> <!-- depending on your project -->
                <target>1.8</target> <!-- depending on your project -->
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.seasar.doma</groupId>
                        <artifactId>doma-processor</artifactId>
                        <version>${doma.version}</version>
                    </path>
                </annotationProcessorPaths>
                <compilerArgs>
                    <!-- if you are using a Maven project in Eclipse, this argument is required -->
                    <arg>-Adoma.resources.dir=${project.basedir}/src/main/resources</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

For Kotlin projects, see Kotlin document.

Documentation

https://doma.readthedocs.io/

Chatroom

https://domaframework.zulipchat.com

Related projects

Major versions

Status and Repository

VersionStatusRepositoryBranch
Doma 1stablehttps://github.com/seasarorg/doma/master
Doma 2stablehttps://github.com/domaframework/doma/master

Compatibility matrix

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

Backers

If you use Doma in your project or enterprise and would like to support ongoing development, please consider becoming a backer. [Become a backer]

Our top backers are shown below!

<a href="https://opencollective.com/doma/backer/0/website" target="_blank"><img src="https://opencollective.com/doma/backer/0/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/1/website" target="_blank"><img src="https://opencollective.com/doma/backer/1/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/2/website" target="_blank"><img src="https://opencollective.com/doma/backer/2/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/3/website" target="_blank"><img src="https://opencollective.com/doma/backer/3/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/4/website" target="_blank"><img src="https://opencollective.com/doma/backer/4/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/5/website" target="_blank"><img src="https://opencollective.com/doma/backer/5/avatar.svg"></a> <a href="https://opencollective.com/doma/backer/6/website" target="_blank"><img src="https://opencollective.com/doma/backer/6/avatar.svg"></a>