Skip to content

Commit c7f7d98

Browse files
authored
Add CLAUDE.md documentation for Claude Code integration (#1356)
2 parents ef560f4 + 699be83 commit c7f7d98

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

CLAUDE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Doma is a database access framework for Java 17+ that uses compile-time annotation processing. It provides type-safe database operations through a Criteria API and SQL templates ("two-way SQL"). The project is organized into multiple modules with comprehensive integration testing across various databases.
8+
9+
## Build Commands
10+
11+
### Core Development
12+
- `./gradlew build` - Build all modules with Spotless formatting applied
13+
- `./gradlew test` - Run tests for all modules (defaults to H2 database)
14+
- `./gradlew spotlessApply` - Apply code formatting (automatically runs with build)
15+
- `./gradlew spotlessCheck` - Check code formatting compliance
16+
17+
### Testing with Different Databases
18+
The project supports extensive database testing. Tests can be run against specific databases:
19+
- `./gradlew h2` - Run tests against H2 (in-memory)
20+
- `./gradlew mysql` - Run tests against MySQL 5.7 (via Testcontainers)
21+
- `./gradlew mysql8` - Run tests against MySQL 8.0 (via Testcontainers)
22+
- `./gradlew oracle` - Run tests against Oracle 21c (via Testcontainers)
23+
- `./gradlew postgresql` - Run tests against PostgreSQL 12 (via Testcontainers)
24+
- `./gradlew sqlite` - Run tests against SQLite
25+
- `./gradlew sqlserver` - Run tests against SQL Server 2019 (via Testcontainers)
26+
- `./gradlew testAll` - Run tests against all supported databases
27+
28+
### Single Test Execution
29+
To run a specific test class:
30+
```bash
31+
./gradlew :module-name:test --tests "ClassName"
32+
# Example: ./gradlew :doma-core:test --tests "ConfigTest"
33+
```
34+
35+
To run integration tests:
36+
```bash
37+
./gradlew :integration-test-java:test --tests "TestClassName"
38+
```
39+
40+
## Module Architecture
41+
42+
### Core Modules
43+
- **doma-core**: Main framework containing annotations, JDBC abstractions, query builders, and type system
44+
- **doma-processor**: Annotation processor that generates metamodel classes and validates SQL at compile time
45+
- **doma-kotlin**: Kotlin-specific extensions and integration
46+
- **doma-slf4j**: SLF4J logging integration
47+
- **doma-template**: SQL template processing utilities
48+
- **doma-mock**: Test utilities and mocks
49+
50+
### Integration Test Modules
51+
- **integration-test-common**: Shared test infrastructure and configuration
52+
- **integration-test-java-common**: Common Java test utilities
53+
- **integration-test-java**: Java-based integration tests
54+
- **integration-test-kotlin**: Kotlin-based integration tests
55+
56+
## Key Architectural Concepts
57+
58+
### Annotation Processing Pipeline
59+
The framework heavily relies on compile-time code generation. The `doma-processor` module generates:
60+
- Entity metamodel classes (ending with `_`)
61+
- DAO implementation classes
62+
- SQL validation and type checking
63+
64+
### SQL Template System ("Two-way SQL")
65+
SQL files use special comments for dynamic SQL that remain valid SQL when run directly:
66+
- `/*%if condition*/` - Conditional blocks
67+
- `/*parameter*/'default'` - Parameter binding
68+
- `/*%expand*/` - Column expansion
69+
70+
### Type System Hierarchy
71+
- **Wrappers** (`org.seasar.doma.wrapper`): Low-level JDBC type mappings
72+
- **Domain Types** (`org.seasar.doma.jdbc.domain`): Custom value object mappings
73+
- **Entity Types** (`org.seasar.doma.jdbc.entity`): ORM entity mappings
74+
- **Criteria API** (`org.seasar.doma.jdbc.criteria`): Type-safe query building
75+
76+
### Configuration System
77+
- `Config` interface defines database connection, naming conventions, dialects
78+
- `SimpleConfig` provides basic implementation
79+
- Dialect classes handle database-specific SQL generation
80+
81+
## Development Guidelines
82+
83+
### Annotation Processing Configuration
84+
When modifying annotation processors or entity/domain classes, the `ap` property in `gradle.properties` can be used to pass additional annotation processor options in CSV format.
85+
86+
### Code Formatting
87+
All code must pass Spotless formatting checks. The build automatically applies formatting, but you can run `./gradlew spotlessCheck` to verify compliance before committing.
88+
89+
### Database Compatibility Testing
90+
When making changes that affect SQL generation or JDBC operations, run tests against multiple databases using `./gradlew testAll` to ensure compatibility.
91+
92+
### Integration Test Structure
93+
Integration tests use Testcontainers for database provisioning. Database URLs are configured in `gradle.properties` with the `TC_DAEMON=true` flag to improve test performance by reusing containers.

0 commit comments

Comments
 (0)