M4 AP-006 Rollback-Semantik und Bootstrap-Scope bereinigen

This commit is contained in:
2026-04-03 09:32:47 +02:00
parent d61299f892
commit 30f070f2a6
3 changed files with 214 additions and 55 deletions
@@ -39,19 +39,20 @@ public class SqliteUnitOfWorkAdapter implements UnitOfWorkPort {
@Override
public void executeInTransaction(Consumer<TransactionOperations> operations) {
Objects.requireNonNull(operations, "operations must not be null");
Connection connection = null;
try {
connection = DriverManager.getConnection(jdbcUrl);
connection.setAutoCommit(false);
TransactionOperationsImpl txOps = new TransactionOperationsImpl(connection);
operations.accept(txOps);
connection.commit();
logger.debug("Transaction committed successfully");
} catch (SQLException e) {
} catch (Exception e) {
// Rollback for ANY exception, not just SQLException
if (connection != null) {
try {
connection.rollback();
@@ -60,6 +61,10 @@ public class SqliteUnitOfWorkAdapter implements UnitOfWorkPort {
logger.error("Failed to rollback transaction: {}", rollbackEx.getMessage(), rollbackEx);
}
}
// Re-throw as DocumentPersistenceException if not already
if (e instanceof DocumentPersistenceException) {
throw (DocumentPersistenceException) e;
}
throw new DocumentPersistenceException("Transaction failed: " + e.getMessage(), e);
} finally {
if (connection != null) {