Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

create-persistence-adapter

/create-persistence-adapter

Tworzy lub aktualizuje adapter trwałości JPA dla agregatu: encję, repozytorium, mapper, migrację Flyway i test @DataJpaTest.

Licencja
MIT
Ostatnia zmiana repozytorium
07.11.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Tworzy lub aktualizuje adapter trwałości JPA dla agregatu: encję, repozytorium, mapper, migrację Flyway i test @DataJpaTest.

Argumenty

/create-persistence-adapter [Repository port or domain aggregate]
Oryginalny opis (EN)

Create or update the JPA persistence adapter for one domain aggregate: entity, Spring Data repository, mapper, 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

  1. Production pattern
  2. Test pattern
  3. Instructions
Sekcje z nagłówków SKILL.md, w oryginale · 57 linii, 428 słów
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, Spring Data repository, mapper, 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-0013](../../../docs/adr/0013-flyway-for-database-migrations.md).

## Production pattern

Copy the shape of the existing adapters:

| Aggregate | Reference | Shows |
|---|---|---|
| `LeasingApplication` | `LeasingApplicationEntity`, `LeasingApplicationJpaRepository`, `LeasingApplicationEntityMapper`, `LeasingApplicationPersistenceAdapter` | a separate mapper, 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.
- **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)` ↔ `UUID`).
- **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`).

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, repository, mapper, adapter and migration.
4. **Verify:** the adapter 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.

Wersje

RepozytoriumWynikLicencja
Ta strona · Miragon/process-engine-blueprints90MIT
Miragon/process-engine-blueprints100MIT
Miragon/process-engine-blueprints90MIT
Miragon/process-engine-blueprints90MIT
Miragon/process-engine-blueprints90MIT

Migawka bazy z 13.11.2026 · wersja paczki 038dd8989ce3 (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
    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.
  • 100spring-data-jpa
    Pomaga w warstwie trwałości JPA, czyli w konwencjach encji, zapytaniach, projekcjach i unikaniu N+1.
  • 100spring-data-jpa
    Projektuje encje JPA, repozytoria i zapytania w Spring Data, unikając problemu N+1 i prowadząc migracje Flyway lub Liquibase.
  • 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.
  • 100repository
    Wyjaśnia, jak działa repozytorium Protean, czyli abstrakcja trwałości agregatów w DDD ukrywająca bazę danych.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.