A Spring Boot 4 data-layer implementation tailored for Domain-Driven Design (DDD). Use this when implementing JPA or JDBC aggregates, Spring Data repositories, transactional service boundaries, projections, or entity auditing. It includes support for aggregate roots via AbstractAggregateRoot, mapping and persistence of value objects, and use of EntityGraph or fetch-joins to prevent N+1 select issues. Also covers Spring Boot 4 specifics such as JSpecify null-safety annotations and AOT-compatible repository patterns for native-image readiness. For DDD concepts and design decisions, see the domain-driven-design skill.
Implements DDD tactical patterns with Spring Data JPA and Spring Data JDBC in Spring Boot 4.
| Choose | When | |--------|------| | Spring Data JPA | Complex queries, existing Hibernate expertise, need lazy loading | | Spring Data JDBC | DDD-first design, simpler mapping, aggregate-per-table, no lazy loading |
Spring Data JDBC enforces aggregate boundaries naturally—recommended for new DDD projects.
See WORKFLOW.md for detailed step-by-step instructions with code examples.
See EXAMPLES.md for complete working examples including:
@NullMarked and @Nullable annotationsjakarta.* namespaceList<T> instead of Iterable<T>New repository interface returning List<T> for better API ergonomics:
// OLD: CrudRepository returns Iterable<T>
public interface UserRepository extends CrudRepository<User, Long> {
Iterable<User> findAll(); // Requires conversion to List
}
// NEW: ListCrudRepository returns List<T>
public interface UserRepository extends ListCrudRepository<User, Long> {
List<User> findAll(); // Direct List return
List<User> findAllById(Iterable<Long> ids); // Also List
}
// Can also extend both for full functionality
public interface UserRepository extends
ListCrudRepository<User, Long>,
ListPagingAndSortingRepository<User, Long> {
}
Benefits: No more StreamSupport.stream(iterable.spliterator(), false).toList() conversions.
| Need | Skill |
|------|-------|
| DDD concepts and design | domain-driven-design |
| REST API for aggregates | spring-boot-web-api |
| Module boundaries | spring-boot-modulith |
| Repository testing | spring-boot-testing |
| Anti-Pattern | Fix |
|--------------|-----|
| FetchType.EAGER on associations | Use LAZY + @EntityGraph when needed |
| Returning entities from controllers | Convert to DTOs in service layer |
| @Transactional on private methods | Use public methods (proxy limitation) |
| Missing readOnly = true on queries | Add for read operations (performance) |
| Direct aggregate-to-aggregate references | Reference by ID only |
| Multiple aggregates in one transaction | Use domain events for eventual consistency |
repository.save() before events dispatch@DataJpaTest — Use TestEntityManager for setupnpx skills add joaquimscosta/Spring Boot 数据层 DDD下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer