ワンクリックで
implement-audit-logging
Implement audit tracking and history endpoints for an existing domain object using Hibernate Envers.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Implement audit tracking and history endpoints for an existing domain object using Hibernate Envers.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | implement-audit-logging |
| description | Implement audit tracking and history endpoints for an existing domain object using Hibernate Envers. |
Implement Hibernate Envers audit logging and a history retrieval endpoint for an existing domain object within the Hexagonal Architecture.
This skill leverages the native Envers entity tracking (track_entities_changed_in_revision: true) and relies on the global envers_transaction_log without creating custom tracking tables.
${input:EntityName}—The name of the domain object (for example Property, EntityTemplate).${input:IdentifierType}—The primary identifier type of the object (for example UUID, String).If the entity name or identifier type cannot be determined from the conversation, ask the user before proceeding. Verify that the target JPA entity exists in the infrastructure.adapters.persistence.model package before attempting any modifications.
revinfo or custom tracking tables.@JsonNaming(SnakeCaseStrategy.class) for all API outputs.Locate the target [EntityName]JpaEntity in infrastructure/adapters/persistence/model/.
org.hibernate.envers.Audited annotation to the class.@NotAudited only to lazy relationships or fields that should strictly not trigger audit records.Create a new migration script in src/main/resources/db/migration/.
[entity_name]_aud.id (or primary key), rev (BIGINT NOT NULL), and revtype (SMALLINT).CONSTRAINT fk_[entity_name]_aud_revinfo FOREIGN KEY (rev) REFERENCES envers_transaction_log (rev) ON DELETE CASCADE.Create an interface [EntityName]AuditPort in domain/port/audit/.
List<[EntityName]AuditInfo> getAuditHistory([IdentifierType] id);.Create Postgres[EntityName]AuditAdapter in infrastructure/adapters/persistence/ implementing the port.
AuditReaderFactory.get(entityManager).createQuery().forRevisionsOfEntity([EntityName]JpaEntity.class, false, true) to fetch revisions.Object[] containing the Entity snapshot, CustomRevisionEntity, and RevisionType to the domain AuditInfo model.CustomRevisionEntity.getAuthId() to the modifiedBy field.Create [EntityName]AuditService in domain/service/[entity_name]/.
@Transactional(readOnly = true).Create [EntityName]AuditDtoOut in infrastructure/adapters/api/dto/out/.
@Data, @Builder, and @JsonNaming(SnakeCaseStrategy.class). Include fields: revisionNumber, revisionDate, revisionType, modifiedBy, and snapshot.AuditController to define @GetMapping("entities/[object-plural]/{id}").@Operation, @ApiResponse).SnakeCaseStrategy.Create an Architectural Decision Record (ADR) document for decision documentation. Use this when asked to document a new architectural decision.
Create or update documentation pages for the IDP-Core documentation site. Use this when asked to write, edit, or restructure content in the docs/src/ folder.