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

Single TransactionTemplate to perform variations of transaction configurations [SPR-17491] #22023

spring-projects-issues opened this issue Nov 13, 2018 · 1 comment
in: data status: waiting-for-triage


Copy link

@spring-projects-issues spring-projects-issues commented Nov 13, 2018

Tadaya Tsuyukubo opened SPR-17491 and commented

With TransactionTemplate, for example, setReadOnly(true) is called, all executions with this template becomes readOnly transactions. If I want to perform another transaction with non-readonly, I need to create another template and so for all variation of transactions.

Instead, It would be nice to perform various transaction configurations with single TransactionTemplate.


For example:


public <T> T execute(Consumer<DefaultTransactionDefinition> txConfig, TransactionCallback<T> action) throws TransactionException 



template.execute( txConfig -> {
 }, status -> {
   // action to perform in transaction



No further details from SPR-17491

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 14, 2018

Tadaya Tsuyukubo commented

Thinking a bit more, TransactionTemplate may not be a good place to add since it is a stateful for transaction definitions.


So, maybe something like:

public class SimpleTransactionTemplate {
   // with default
   public <T> T execute(TransactionCallback<T> action) throws TransactionException {
   public <T> T execute(TransactionDefinition definition, TransactionCallback<T> action) throws TransactionException {



If API looks ok, then I can write a PR for this.

@spring-projects-issues spring-projects-issues added status: waiting-for-triage in: data type: enhancement and removed type: enhancement labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: data status: waiting-for-triage
None yet

No branches or pull requests

1 participant