create-persistence-adapter
/create-persistence-adapter
Tworzy lub aktualizuje adapter trwałości JPA dla agregatu, w tym workflow VanillaBP dla wniosków leasingowych, z migracją i testem.
- Autor
- Miragon ↗
- Repozytorium
- process-engine-blueprints ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 2
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.
Co robi i kiedy
Tworzy lub aktualizuje adapter trwałości JPA dla agregatu, w tym workflow VanillaBP dla wniosków leasingowych, z migracją i testem.
Argumenty
/create-persistence-adapter [Repository port or domain aggregate]
Oryginalny opis (EN)
Create or update the JPA persistence adapter for one domain aggregate: entity (for leasing applications the VanillaBP workflow aggregate), Spring Data repository, the @Component implementing the outbound Repository port, its Flyway migration and its @DataJpaTest. Use when the user asks to create a persistence adapter, persist an aggregate, add a column or a query, or add an outbound db adapter.
Jak działa
- Production pattern
- Test pattern
- Instructions
Podgląd SKILL.md
---
name: create-persistence-adapter
argument-hint: "[Repository port or domain aggregate]"
description: "Create or update the JPA persistence adapter for one domain aggregate: entity (for leasing applications the VanillaBP workflow aggregate), Spring Data repository, the @Component implementing the outbound Repository port, its Flyway migration and its @DataJpaTest. Use when the user asks to create a persistence adapter, persist an aggregate, add a column or a query, or add an outbound db adapter."
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
---
# Skill: create-persistence-adapter
Files per aggregate in `adapter/outbound/db/` (package `io.miragon.blueprint` under
`service/app/src/main/`), the tests next to them in the test tree. The rules are in `AGENTS.md`
(Architecture, Testing) and [ADR-0010](../../../docs/adr/0010-flyway-for-database-migrations.md).
## Production pattern
Copy the shape of the existing adapters:
| Aggregate | Reference | Shows |
|---|---|---|
| `LeasingApplication` | `LeasingApplicationAggregate` (in `adapter/process/`), `LeasingApplicationJpaRepository`, `LeasingApplicationPersistenceAdapter` | the VanillaBP workflow aggregate as the entity, mapped by its own `of`/`adopt`/`toDomain`; a filtered and paged query behind the port's own `Criteria`/`Page` |
| `Bike` | `BikeEntity`, `BikePortfolioJpaRepository`, `BikePortfolioPersistenceAdapter` | a small aggregate mapped inside the adapter |
- The adapter is a `@Component` implementing exactly the outbound `*Repository` port.
- **The leasing application is the workflow aggregate.** VanillaBP loads it by its id, so the table is
keyed by text, and it also holds the state of the workflow (the open clarification task, the
gateway decisions). `save` loads the existing aggregate and `adopt`s the domain's changes, so that
state survives; only the fields marked `@JsonProperty` reach the engine.
- **Spring Data types stop at the adapter.** The port owns `Criteria`/`Page`; the adapter translates
(`PageRequest`, `Sort`) and returns the port's types.
- Columns are `snake_case`, enums `@Enumerated(EnumType.STRING)`, value objects are mapped to
primitives and back (`ApplicationId(UUID)` ↔ `String`).
- **Flyway owns the schema.** Hibernate only validates (`ddl-auto: validate`), so every entity change
ships with the next `service/app/src/main/resources/db/migration/V<n>__<what>.sql`; never edit an
applied migration. A new filter or sort column gets an index.
## Test pattern
`@DataJpaTest` + `@ActiveProfiles("test")` + `@Import(<Adapter>)` (reference:
`LeasingApplicationPersistenceAdapterTest`), one test per port method and per filter, including the
empty result:
- **Round trip through a cleared context:** save, `flush()`, `clear()`, then read back, or the test only
reads the first-level cache.
- **Read tests seed independently** of the adapter under test: an `@Sql` script in
`service/app/src/test/resources/sql/` (see `leasing-application.sql` and the `findById` test), so a
broken `save` cannot hide a broken read. The older `findAll` tests and `BikePortfolioPersistenceAdapterTest`
still seed through `save`; don't copy that.
- **A new column** also goes into the seed script and into the defaults of the domain test factory
(`TestObjectBuilder`). The test schema is generated from the entities (`ddl-auto: create-drop`), so
a seed without the column still runs and the round trip silently compares `null`.
- Compare whole objects (`usingRecursiveComparison()`) built with the domain test factory
(`TestObjectBuilder`). The aggregate's mapping gets its own plain unit test for every field
(`LeasingApplicationAggregateTest`); a column that only the workflow writes is covered there and by
the adapter test that saves a known application and keeps the workflow's state.
Tests run against H2 with Flyway off; the migration is checked when the service starts against
Postgres, so start it once after a schema change.
## Instructions
1. **Resolve the aggregate** from `$ARGUMENTS` (a `*Repository` port in `application/port/outbound/` or
an aggregate in `domain/`), else list the ports and ask.
2. **Derive the target state:** columns, value-object mapping, the queries the port needs. Add only
what is missing to existing files.
3. **Write the tests first**, then entity (or aggregate), repository, mapping, adapter and
migration.
4. **Verify:** the adapter and mapper tests by name, then the architecture tests (`AGENTS.md` →
Verify After Each Task); with the stack running, start the service once so Hibernate validates the
schema against the migrated Postgres.
<!-- variant:blueprint -->
5. **Both variants:** the same classes and tests in `kotlin-gradle/` and `java-maven/`; the migration
is byte-identical in both.
<!-- /variant:blueprint -->
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · Miragon/process-engine-blueprints | 90 | MIT |
| Miragon/process-engine-blueprints | 100 | MIT |
| Miragon/process-engine-blueprints | 90 | MIT |
| Miragon/process-engine-blueprints | 90 | MIT |
| Miragon/process-engine-blueprints | 90 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki da36955f88be (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100spring-data-jpa
Pomaga w warstwie trwałości JPA, czyli w konwencjach encji, zapytaniach, projekcjach i unikaniu N+1. - 100spring-data-jpa
Dodaje trwałość JPA do istniejącego projektu Spring Boot 4 z encjami, repozytoriami, migracjami Flyway i testami. - 100spring-testing-persistence
Testuje warstwę trwałości Spring Boot: repozytoria, zapytania, mapowania JPA, ograniczenia bazy i migracje z Testcontainers. - 100repository
Wyjaśnia, jak działa repozytorium Protean, czyli abstrakcja trwałości agregatów w DDD ukrywająca bazę danych. - 85ai-persistence/build-prisma-adapter
Pisze adapter trwałości czatu TanStack AI dla aplikacji z Prisma, na podstawie istniejącego klienta i pliku schema.prisma. - 100spring-data-jpa
Generuje i refaktoryzuje encje, repozytoria, projekcje i zapytania JPA w Spring Boot 4 z Hibernate 7.