doma

by domaframework

domaframework / doma

DAO oriented database mapping framework for Java 8+

235 Stars 51 Forks Last release: 13 days ago (2.44.0) Apache License 2.0 2.4K Commits 134 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Doma

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 docs javadoc Google group : doma-user 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 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:

@Dao
public interface EmployeeDao {

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

See SQL templates for more information.

More Examples

Try Getting started.

For more complete examples, see simple-examples and spring-boot-jpetstore.

Installing

Gradle

For Java projects:

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

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.44.0")
    kapt("org.seasar.doma:doma-processor:2.44.0")
}

Maven

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

For Java projects:

...

    2.44.0

...

    
        org.seasar.doma
        doma-core
        ${doma.version}
    

...

    
        
            org.apache.maven.plugins
            maven-compiler-plugin
            3.8.1
            
                1.8 
                1.8 
                
                    
                        org.seasar.doma
                        doma-processor
                        ${doma.version}
                    
                
            
        
    

For Kotlin projects, see Kotlin document.

Documentation

https://doma.readthedocs.io/

Google Group

https://groups.google.com/g/doma-user

Related projects

Major versions

Status and Repository

| Version | Status | Repository | Branch | | -------------------------------------- | ----------------- | -------------------------------------- | ------ | | Doma 1 | stable | https://github.com/seasarorg/doma/ | master | | Doma 2 | stable | https://github.com/domaframework/doma/ | 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 |

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.