GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - domaframework/doma: DAO oriented database mapping framework for Java

BranchesTags
Open more actions menu

Latest commit

 

History

4,185 Commits
4,185 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
doma-core
doma-core
 
 
doma-kotlin
doma-kotlin
 
 
doma-mock
doma-mock
 
 
doma-processor
doma-processor
 
 
doma-slf4j
doma-slf4j
 
 
doma-template
doma-template
 
 
gradle
gradle
 
 
integration-test-common
integration-test-common
 
 
integration-test-java-common
integration-test-java-common
 
 
integration-test-java
integration-test-java
 
 
integration-test-kotlin
integration-test-kotlin
 
 
spotless
spotless
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.readthedocs.yaml
.readthedocs.yaml
 
 
.sdkmanrc
.sdkmanrc
 
 
AGENTS.md
AGENTS.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
RELEASE_OPERATIONS.md
RELEASE_OPERATIONS.md
 
 
SECURITY.md
SECURITY.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
renovate.json
renovate.json
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

Doma

Doma is a database access framework for Java with several notable strengths:

  • It checks and generates source code at compile time using annotation processing.
  • It supports associations between entities.
  • It offers a type-safe Criteria API.
  • It includes SQL templates, known as “two-way SQL.”
  • It runs independently, without relying on any other libraries.

Build Status javadoc project chat X Ask DeepWiki

Backers

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

Supported by

JetBrains logo.


Prerequisite

The latest major version of Doma supports Java 17 and above. If you are using Java 8, please use Doma 2.

See also Major versions.

Supported databases

We are testing against the following databases:

Database version status
H2 Database 2.5.252 stable
MySQL v5 5.7 stable
MySQL v8 8.0.36 stable
Oracle Database Free 23.4 stable
PostgreSQL 12.20 stable
SQLite 3.54.1.0 stable
SQL Server 2019 stable

Examples

Type-safe Criteria API

This code uses a type-safe Criteria API to fetch employees from a specific department while establishing associations between the related entities:

var queryDsl = new QueryDsl(config);
var e = new Employee_();
var d = new Department_();

var employees = queryDsl
    .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();

See Unified Criteria API for more information.

SQL templates

This code uses an SQL template to fetch employees from a specific department while establishing associations between the related entities:

@Dao
public interface EmployeeDao {

  @Sql(
    """
    select
      /*%expand*/*
    from
      EMPLOYEE e
      inner join
      DEPARTMENT d
        on e.departmentId = d.departmentId
    where
      /*%if departmentName != null*/
      d.DEPARTMENT_NAME = /*departmentName*/'test'
      /*%end*/
    """)
  @Select(aggregateStrategy = EmployeeStrategy.class)
  List<Employee> selectByDepartmentName(String departmentName);

  @AggregateStrategy(root = Employee.class, tableAlias = "e")
  interface EmployeeStrategy {
    @AssociationLinker(propertyPath = "department", tableAlias = "d")
    BiFunction<Employee, Department, Employee> department = (e, d) -> {
      e.setDepartment(d);
      d.getEmployees().add(e);
      return e;
    };
  }
}

See SQL templates and Aggregate strategies for more information.

More Examples

Try Getting started and simple-examples.

Using Doma with AI coding agents

Doma checks SQL templates, bind variables and DAO signatures at compile time, so many mistakes in code written by AI coding agents fail the build with a DOMA error that the agent can read and fix, instead of failing later at runtime.

  • llms.txt summarizes how to write Doma code, including the SQL template grammar and common pitfalls. Give it to your coding agent as context.
  • doma-agent-bench measures how well coding agents build features with Doma and records where they fail. Its results guide improvements to Doma's documentation, error messages and compile-time checks.

Installing

Gradle

For Java projects:

plugins {
    id("org.domaframework.doma.compile") version "4.0.4"
}

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

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

plugins {
  id("org.domaframework.doma.compile") version "4.0.4"
}

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

Maven

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

For Java projects:

...
<properties>
    <doma.version>3.15.0</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>17</source> <!-- depending on your project -->
                <target>17</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

  • quarkus-doma - Supports integration with Quarkus
  • doma-spring-boot - Supports integration with Spring Boot
  • doma-compile-plugin - Makes compilation easy
  • doma-codegen-plugin - Generates Java and SQL files

Major versions

Status and Repository

Version Status Repository Branch
Doma 1 limited-support https://github.com/seasarorg/doma/ master
Doma 2 limited-support https://github.com/domaframework/doma/ 2.x
Doma 3 stable https://github.com/domaframework/doma/ master

Compatibility matrix

Doma 1 Doma 2 Doma 3
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 v
Java 18 v v
Java 19 v v
Java 20 v v
Java 21 v v
Java 22 v v
Java 23 v
Java 24 v
Java 25 v
Java 26 v
Java 27 v

About

DAO oriented database mapping framework for Java

docs.domaframework.org

Topics

annotation-processordaodomajavajdbckotlinno-dependenciessql

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

512 stars

Watchers

25 watching

Forks

75 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.