Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EXPOSED-593 Rollback ExposedSQLException when use SpringTransactionManager #2398

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

FullOfOrange
Copy link
Contributor

@FullOfOrange FullOfOrange commented Feb 8, 2025

Description

Summary of the change:

  • Add ExposedSpringTransactionAttributeSource to fix transaction not rollback when an ExposedSQLException thrown when using SpringTransactionManager.

  • Added @bean settings to spring-boot-starter

Detailed description:

  • What: Introduces ExposedSpringTransactionAttributeSource. This is an implementation of TransactionAttributeSource, a class for setting attributes on a transaction, and a class for adding ExposedSQLException as a rollback rule.
  • Why: Spring only rollback UncheckedExceptions when using the @Transactional annotation, but ExposedSQLException is a CheckedException and cannot be rolled back. This makes the behavior different from the default exposed transaction, and want to fix it.
  • How:
    • Implemented ExposedSpringTransactionAttributeSource to allow you to add an exception to the rollback rule.
      • If you use spring-boot-starter, it will automatically register the bean for you.
      • If you set it up yourself, you can register the ExposedSpringTransactionAttributeSource as a bean yourself and use it. (set up same as spring-boot-starter).

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

commit b1f340f
Author: 육진혁 (Ivan) <10372359+FullOfOrange@users.noreply.github.com>
Date:   Sat Feb 8 16:41:56 2025 +0900

    fix: detekt and api check

commit df9f29e
Merge: c7c781d a32e1f6
Author: 육진혁 (Ivan) <10372359+FullOfOrange@users.noreply.github.com>
Date:   Sat Feb 8 16:36:11 2025 +0900

    Merge branch 'main' into fulloforange/rollback-spring

commit c7c781d
Author: 육진혁 (Ivan) <10372359+FullOfOrange@users.noreply.github.com>
Date:   Sat Feb 8 16:33:54 2025 +0900

    Add ExposedSpringTransactionAttributeSource to rollback exception
@bog-walk bog-walk self-assigned this Feb 10, 2025
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.

2 participants