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

Enable custom default value for @Transactional's rollbackFor argument [SPR-3027] #7713

Closed
spring-projects-issues opened this issue Jan 10, 2007 · 3 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Christoph Hilmes opened SPR-3027 and commented

Just resently there was an issue about setting a default value for the timeout-argument of the @Transactional-Annotation. I´m sorry to bring up this issue again, but for me it would be nice if i could set a default value for the rollbackFor argument. At the moment i have to set this argument to my custom exceptions for every class which is a little bit cumbersome. Maybe you can do the same thing as for "timeout" once again for this argument!? Thanks.


Affects: 2.0.1

3 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

Karl Moore commented

The timeout issue is this one.
http://forum.springframework.org/showthread.php?t=32917

Issue came from here.
http://forum.springframework.org/showthread.php?p=95074

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

The default timeout issue has been addressed at the transaction manager level. Rollback-for is specific to declarative transactions, i.e. the TransactionInterceptor, so we have to address it at that level instead...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

As of Spring 3.0 M3, we support @Transactional as a meta-annotation on custom annotations. E.g.:

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Transactional(rollbackFor=Exception.class, noRollbackFor={IOException.class})
public @interface MyTx {
}

And then using this custom annotation instead of the standard @Transactional annotation:

@MyTx
public void myServiceMethod {
...
}

This should be a convenient and elegant solution to any repetitive @Transactional usage!

@spring-projects-issues spring-projects-issues added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 M3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants