1a0a56a626
Replace the stale multi-module java/mss-failsafe skeleton (old user-management prototype) with the active single-module machine-safety inspection app that was living in its own standalone repo at the repo root. - Remove old java/mss-failsafe/ multi-module tree (mss, userdata, userManagement, mssfailsafe.datalayer, mssfailsafeWeblayer) incl. committed build artifacts - Add the active app (PrimeFaces 11 / JSF 2.3 / Hibernate 5.6 / iText / POI) flattened into java/mss-failsafe/ as the only mss-failsafe in git - Working tree captured = master tip 2a142b5 + in-progress uncommitted work (incl. .github/*.instructions.md AI-context files) - Archive the standalone repo's 33-commit history in GIT_HISTORY_ARCHIVE.md since its .git was not migrated This is the source of truth / base for the upcoming upgraded rewrite.
41 lines
1.8 KiB
Markdown
Executable File
41 lines
1.8 KiB
Markdown
Executable File
# Transactions Instructions
|
|
|
|
Aktualisiert: 2025-10-20
|
|
|
|
## Kontext
|
|
Container-Managed Transaktionen (Java EE). Verwendung von `@Transactional` auf Manager-Methoden für Schreiboperationen.
|
|
|
|
## Grundsätze
|
|
- Jede persistierende Operation (create, edit, remove) innerhalb einer Transaktion.
|
|
- `save` und `saveAll` bereits mit `@Transactional` versehen.
|
|
- Leseoperationen können ohne Annotation auskommen (Default: kein Write-Lock nötig).
|
|
|
|
## Batch Operationen
|
|
- `saveAll(Collection<T>)`: Ein Transaktionskontext für gesamte Collection -> entweder komplett erfolgreich oder Abbruch beim Fehler.
|
|
- Optimierungspotential: Fehler sammeln, nicht sofort abbrechen.
|
|
|
|
## Refresh
|
|
- `refresh(entity)` führt merge aus; wenn `id == null` vorher persist -> bleibt innerhalb Transaktion falls aufgerufen durch `save`/`saveAll`.
|
|
|
|
## Remove
|
|
- `remove(entity)` ohne `@Transactional` in Basisklasse -> Empfehlung: Annotation hinzufügen in konkretem Manager wenn Delete-Fachlogik erweitert wird.
|
|
|
|
## Edge Cases
|
|
- Verschachtelte Aufrufe (save -> intern create/edit): Container handhabt Propagation (`REQUIRED`).
|
|
- LazyInitializationException vermeiden: innerhalb Transaktion initialisieren.
|
|
|
|
## Empfohlene Annotationen
|
|
- Zusätzliche fachliche Write-Methoden stets mit `@Transactional` versehen.
|
|
- Pure Read: Performancekritisch -> ggf. explizit `@Transactional(Transactional.TxType.SUPPORTS)` oder weglassen.
|
|
|
|
## Fehlerfall Verhalten
|
|
- Ungefangene RuntimeException -> Rollback durch Container.
|
|
- Aktuell Exceptions geloggt & boolean false -> verhindert Rollback. Verbesserung: BusinessException throw + Rollback.
|
|
|
|
## Generator Leitplanken
|
|
- Keine eigenen manuell geöffneten Transaktionen (kein `UserTransaction`).
|
|
- Konsistenz: Schreibmethoden annotieren, Leseoperationen nur bei Bedarf.
|
|
|
|
---
|
|
|