Skip to content

feat(core): remove dependency between audit search and entity template - #140

Open
RVANDO12 wants to merge 4 commits into
mainfrom
issue/audit/resilient
Open

feat(core): remove dependency between audit search and entity template#140
RVANDO12 wants to merge 4 commits into
mainfrom
issue/audit/resilient

Conversation

@RVANDO12

@RVANDO12 RVANDO12 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

PR Description

feat(database): update audit retrieval mechanism to use envers tables exclusively

What this PR Provides

  • Refactors the audit retrieval mechanism to query entity IDs exclusively using the Hibernate Envers AuditReader.
  • Removes the dependency on standard entity and entity template tables for fetching audit records.
  • Allows retrieving the complete audit history for deleted entities, as the audit trail is now queried independently from the main tables.
  • Throws an EntityNotFoundException only if the requested entity identifier cannot be found within the audit history itself.
  • Throws an EntityTemplateNotFoundException only if the requested entity template identifier cannot be found within the audit history itself.

Fixes

NA

Review

The reviewer must double-check these points:

  • The reviewer has tested the feature
  • The reviewer has reviewed the implementation of the feature
  • The documentation has been updated
  • The feature implementation respects the Technical Doc / ADR previously produced
  • The Pull Request title has a ! after the type/scope to identify the breaking
    change in the release note and ensure we will release a major version.

How to test

The initial state:

  • Ensure you have an existing entity in the system.

  • Delete this entity (and optionally its template) so that it no longer exists in the standard database tables but remains in the Envers _aud tables.

What and how to test:

  • Perform a GET request to the audit API endpoint at /api/v1/audit/entities/{templateIdentifier}/{entityIdentifier} using the deleted entity's identifiers.

Expected results:

The request should return a 200 OK status code and successfully retrieve the list of EntityAuditDtoOut revision history (including CREATED, UPDATED, and DELETED operations) despite the entity missing from the standard tables.

Last check, recreate entity template and entity, call get audit on the couple of identifier :

[
  {
    "modified_by": "local-developer",
    "revision_date": "2026-09-04T08:21:00.948Z",
    "revision_number": 26405,
    "revision_type": "CREATED",
    "snapshot": {
      "identifier": "242816059",
      "name": "CN-HAWKEYE-PRICE",
      "properties": [],
      "relations": [
        {
          "name": "smax_service-supported_by-support_group",
          "target_entity_identifiers": [
            "CS-HAWKEYE-PRICE-CN"
          ],
          "target_template_identifier": "supportgroup"
        }
      ],
      "template_identifier": "smax-service"
    }
  },
  {
    "modified_by": "local-developer",
    "revision_date": "2026-09-04T08:14:15.755Z",
    "revision_number": 26302,
    "revision_type": "DELETED",
    "snapshot": {
      "identifier": "242816059",
      "name": "CN-HAWKEYE-PRICE",
      "properties": [],
      "relations": [
        {
          "name": "smax_service-supported_by-support_group",
          "target_entity_identifiers": [
            "CS-HAWKEYE-PRICE-CN"
          ],
          "target_template_identifier": "supportgroup"
        }
      ],
      "template_identifier": "smax-service"
    }
  },
  {
    "modified_by": "local-developer",
    "revision_date": "2026-09-04T07:32:35.944Z",
    "revision_number": 9138,
    "revision_type": "CREATED",
    "snapshot": {
      "identifier": "242816059",
      "name": "CN-HAWKEYE-PRICE",
      "properties": [],
      "relations": [
        {
          "name": "smax_service-supported_by-support_group",
          "target_entity_identifiers": [
            "CS-HAWKEYE-PRICE-CN"
          ],
          "target_template_identifier": "supportgroup"
        }
      ],
      "template_identifier": "smax-service"
    }
  }
]

Breaking changes (if any)

  • N/A

@github-code-quality

github-code-quality Bot commented Sep 4, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Java

Java / code-coverage/jacoco

The overall line coverage in commit 1f12724 in the issue/audit/resilien... branch remains at 91%, unchanged from commit 6976334 in the main branch.


Updated September 04, 2026 09:26 UTC

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant