Skip to content

Commit 00b2606

Browse files
authored
Update README.md (#1316)
2 parents 53e926b + 5bce36b commit 00b2606

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

README.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
Doma
22
====
33

4-
Doma is a database access framework for Java.
5-
Doma has various strengths:
4+
Doma is a database access framework for Java with several notable strengths:
65

7-
- Verifies and generates source code **at compile time** using [annotation processing][apt].
8-
- Provides type-safe Criteria API.
9-
- Supports Kotlin.
10-
- Uses SQL templates, called "two-way SQL".
11-
- Has no dependence on other libraries.
6+
- It checks and generates source code at compile time using annotation processing.
7+
- It supports associations between entities.
8+
- It offers a type-safe Criteria API.
9+
- It includes SQL templates, known as “two-way SQL.”
10+
- It runs independently, without relying on any other libraries.
1211

1312
[![Build Status](https://github.com/domaframework/doma/workflows/Java%20CI%20with%20Gradle/badge.svg)](https://github.com/domaframework/doma/actions?query=workflow%3A%22Java+CI+with+Gradle%22)
1413
[![javadoc](https://javadoc.io/badge2/org.seasar.doma/doma-core/javadoc.svg)](https://javadoc.io/doc/org.seasar.doma/doma-core)
@@ -64,6 +63,9 @@ Examples
6463

6564
### Type-safe Criteria API
6665

66+
This code uses a type-safe Criteria API to fetch employees from a specific department
67+
while establishing associations between the related entities:
68+
6769
```java
6870
var queryDsl = new QueryDsl(config);
6971
var e = new Employee_();
@@ -85,23 +87,44 @@ for more information.
8587

8688
### SQL templates
8789

90+
This code uses an SQL template to fetch employees from a specific department
91+
while establishing associations between the related entities:
92+
8893
```java
8994
@Dao
9095
public interface EmployeeDao {
9196

9297
@Sql(
9398
"""
94-
select * from EMPLOYEE where
95-
/*%if salary != null*/
96-
SALARY >= /*salary*/9999
97-
/*%end*/
99+
select
100+
/*%expand*/*
101+
from
102+
EMPLOYEE e
103+
inner join
104+
DEPARTMENT d
105+
on e.departmentId = d.departmentId
106+
where
107+
/*%if departmentName != null*/
108+
d.DEPARTMENT_NAME = /*departmentName*/'test'
109+
/*%end*/
98110
""")
99-
@Select
100-
List<Employee> selectBySalary(BigDecimal salary);
111+
@Select(aggregateStrategy = EmployeeStrategy.class)
112+
List<Employee> selectByDepartmentName(String departmentName);
113+
114+
@AggregateStrategy(root = Employee.class, tableAlias = "e")
115+
interface EmployeeStrategy {
116+
@AssociationLinker(propertyPath = "department", tableAlias = "d")
117+
BiFunction<Employee, Department, Employee> department = (e, d) -> {
118+
e.setDepartment(d);
119+
d.getEmployees().add(e);
120+
return e;
121+
};
122+
}
101123
}
102124
```
103125

104-
See [SQL templates](https://doma.readthedocs.io/en/latest/sql/)
126+
See [SQL templates](https://doma.readthedocs.io/en/latest/sql/) and
127+
[Aggregate strategies](https://doma.readthedocs.io/en/latest/aggregate-strategy/)
105128
for more information.
106129

107130
### More Examples
@@ -238,5 +261,6 @@ Major versions
238261
| Java 21 | | v | v |
239262
| Java 22 | | v | v |
240263
| Java 23 | | | v |
264+
| Java 24 | | | v |
241265

242266
[apt]: https://www.jcp.org/en/jsr/detail?id=269

0 commit comments

Comments
 (0)