M4 AP-006 Rollback-Semantik und Bootstrap-Scope bereinigen
This commit is contained in:
+10
-5
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user