Skip to content

Commit 22d1c9c

Browse files
nakamura-toclaude
andauthored
Convert documentation from reStructuredText to Markdown (#1393)
* docs: Convert documentation from reStructuredText to Markdown Migrate all documentation files from .rst to .md format for improved maintainability and developer experience. Update Sphinx configuration to use MyST parser for Markdown support. Update translation files to reflect content changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: Replace {doc} references with standard Markdown links Convert all Sphinx-style {doc}`path` references to standard Markdown link syntax [](path.md) throughout the documentation. This change affects 21 documentation files and ensures compatibility with standard Markdown processors. - Simple references: {doc}`basic` → [](basic.md) - References with text: {doc}`SQL template <../sql>` → [SQL template](../sql.md) - Relative paths: {doc}`../entity` → [](../entity.md) - Nested paths: {doc}`query/select` → [](query/select.md) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: Replace MyST-style links with standard Markdown links Convert all MyST-specific link syntax to standard Markdown link format for better compatibility and consistency across the documentation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: Add Markdown editor compatibility links and fix typo - Add commented Markdown links for better editor navigation - Fix capitalization typo in faq.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Revert "docs: Add Markdown editor compatibility links and fix typo" This reverts commit 8a87b5d. * docs: Fix capitalization typo in FAQ link description * docs: Update Japanese translations to match RST-to-Markdown conversion - Remove all fuzzy markers from 41 PO files (777 fuzzy messages total) - Convert RST-style formatting to Markdown in Japanese translations - Change double backticks to single backticks for code terms - Update cross-references from :doc:/:ref: to Markdown link format - Preserve translation meaning while updating formatting conventions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: Fix indentation in Kotlin build script example Remove excessive indentation in the Kotlin build.gradle.kts code block to improve readability and consistency with standard formatting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent d65ad0a commit 22d1c9c

File tree

122 files changed

+21158
-18782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+21158
-18782
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
out
1212
.factorypath
1313
/.claude/settings.local.json
14+
/.venv/

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ sphinx-autobuild . _build/html
140140

141141
# Generate translation files
142142
sphinx-build -b gettext . _build/gettext
143+
144+
# Updates Japanese translation files
145+
sphinx-intl update -p _build/gettext -l ja
143146
```
144147

145148
### Documentation Guidelines

docs/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.13

docs/aggregate-strategy.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Aggregate strategies
2+
3+
```{contents}
4+
:depth: 4
5+
```
6+
7+
The aggregate strategy defines how to construct an entity aggregate from an arbitrary SELECT statement.
8+
It provides a structured way to map relational query results into hierarchical entity structures by specifying
9+
how entities should be linked together.
10+
11+
## Aggregate strategy definition
12+
13+
An aggregate strategy is defined by annotating an interface with `@AggregateStrategy`.
14+
This annotation specifies how an entity aggregate is reconstructed from a query result.
15+
16+
```java
17+
@AggregateStrategy(root = Department.class, tableAlias = "d")
18+
interface DepartmentAggregateStrategy {
19+
...
20+
}
21+
```
22+
23+
- The `root` element specifies the entity class that serves as the root of the aggregate.
24+
- The `tableAlias` element defines the alias for the table corresponding to the root entity class.
25+
This alias must be used in the SELECT statement to correctly map query results to entity properties.
26+
27+
## Association linker definition
28+
29+
An aggregate strategy must contain at least one field of type `BiConsumer` or `BiFunction`,
30+
annotated with `@AssociationLinker`.
31+
These functions are responsible for dynamically associating two entity instances.
32+
Use a `BiFunction` when associating immutable entities.
33+
For mutable entities, you may use either a `BiConsumer` or a `BiFunction`.
34+
35+
```java
36+
@AggregateStrategy(root = Department.class, tableAlias = "d")
37+
interface DepartmentAggregateStrategy {
38+
@AssociationLinker(propertyPath = "employees", tableAlias = "e")
39+
BiConsumer<Department, Employee> employees =
40+
(d, e) -> {
41+
d.getEmployees().add(e);
42+
e.setDepartment(d);
43+
};
44+
45+
@AssociationLinker(propertyPath = "employees.address", tableAlias = "a")
46+
BiFunction<Employee, Address, Employee> address =
47+
(e, a) -> {
48+
e.setAddress(a);
49+
return e;
50+
};
51+
}
52+
```
53+
54+
- The first type parameter of a `BiConsumer` or `BiFunction` represents the type of the property owner,
55+
and the second type parameter represents the type of the property.
56+
The third type parameter of a `BiFunction` must be the same as the first one and represents the type of
57+
the entity after the association is applied.
58+
- The `propertyPath` element specifies the name of the target property as a dot-separated path from the root entity class.
59+
- The `tableAlias` element specifies the alias for the table corresponding to the entity class used as the second
60+
type parameter of the `BiConsumer` or `BiFunction`. This alias must be used in the SELECT statement.
61+
62+
## Example
63+
64+
The `DepartmentAggregateStrategy` described above is based on the following entity definitions:
65+
66+
```java
67+
@Entity(naming = NamingType.SNAKE_LOWER_CASE)
68+
public class Department {
69+
@Id Integer id;
70+
String name;
71+
@Association List<Employee> employees = new ArrayList<>();
72+
73+
// getter, setter
74+
}
75+
76+
@Entity(naming = NamingType.SNAKE_LOWER_CASE)
77+
public class Employee {
78+
@Id Integer id;
79+
String name;
80+
Integer departmentId;
81+
Integer addressId;
82+
@Association Department department;
83+
@Association Address address;
84+
85+
// getter, setter
86+
}
87+
88+
@Entity(naming = NamingType.SNAKE_LOWER_CASE)
89+
public class Address {
90+
@Id Integer id;
91+
String street;
92+
93+
// getter, setter
94+
}
95+
```
96+
97+
In entity classes, association properties must be annotated with `@Association`.
98+
These properties can be linked using `@AssociationLinker`.
99+
100+
### Using an aggregate strategy
101+
102+
`DepartmentAggregateStrategy` is used by specifying it in the `aggregateStrategy` element of `@Select`:
103+
104+
```java
105+
@Dao
106+
interface DepartmentDao {
107+
@Select(aggregateStrategy = DepartmentAggregateStrategy.class)
108+
Department selectById(Integer id);
109+
}
110+
```
111+
112+
The `selectById` method requires a SELECT statement like the following:
113+
114+
```sql
115+
select
116+
d.id as d_id,
117+
d.name as d_name,
118+
a.id as a_id,
119+
a.street as a_street,
120+
e.id as e_id,
121+
e.name as e_name,
122+
e.department_id as e_department_id,
123+
e.address_id as e_address_id
124+
from
125+
department d
126+
left outer join
127+
employee e on (d.id = e.department_id)
128+
left outer join
129+
address a on (e.address_id = a.id)
130+
where
131+
d.id = /* id */0
132+
```
133+
134+
:::{note}
135+
The SELECT list must include the IDs of all entities that form the aggregate.
136+
:::
137+
138+
#### Column aliasing rules
139+
140+
- Table aliases must match those defined in `DepartmentAggregateStrategy`.
141+
- Column aliases must begin with the table alias followed by an underscore (`_`).
142+
For example, `d.id` should be aliased as `d_id` and `e.id` as `e_id`.
143+
144+
### Using the expansion directive
145+
146+
By using the [expansion directive](sql.md#expansion-directive), the above SELECT statement can be written more concisely:
147+
148+
```sql
149+
select
150+
/*%expand*/*
151+
from
152+
department d
153+
left outer join
154+
employee e on (d.id = e.department_id)
155+
left outer join
156+
address a on (e.address_id = a.id)
157+
where
158+
d.id = /* id */0
159+
```
160+
161+
#### How expansion works
162+
163+
- The `/*%expand*/*` directive automatically expands into a column list following predefined aliasing rules.
164+
- By default, all columns from all tables are included in the result set.
165+
166+
To selectively expand only specific tables, pass a comma-separated list of table aliases:
167+
168+
```sql
169+
select
170+
/*%expand "e, d" */*,
171+
a.id as a_id,
172+
a.street as a_street
173+
from
174+
department d
175+
left outer join
176+
employee e on (d.id = e.department_id)
177+
left outer join
178+
address a on (e.address_id = a.id)
179+
where
180+
d.id = /* id */0
181+
```
182+
183+
- Here, only columns from tables `e` (`employee`) and `d` (`department`) are expanded.
184+
- The columns from table `a` (`address`) are explicitly specified.

docs/aggregate-strategy.rst

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)