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

Overriding transaction management [BATCH-2294] #1289

Closed
spring-issuemaster opened this issue Aug 14, 2014 · 4 comments
Closed

Overriding transaction management [BATCH-2294] #1289

spring-issuemaster opened this issue Aug 14, 2014 · 4 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 14, 2014

Abhay opened BATCH-2294 and commented

SimpleBatchConfiguration which gets loaded by any of spring application, created transactionManager bean irrespective of whether that bean is already created or not. This results in overriding transaction manager

@ConditionalOnMissingBean could be used for resolution of this issues


Affects: 3.0.1

Reference URL: http://stackoverflow.com/q/25303163/3073323

Issue Links:

  • BATCH-2642 Document how to make Spring Batch work with Spring Data JPA repositories
    ("is depended on by")

Referenced from: pull request #609, and commits a68d700

Backported to: 4.1.0.M3

3 votes, 5 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 14, 2014

Michael Minella commented

Can you please provide your configuration?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 30, 2017

Thiago B. Negri commented

I'm facing the same issue.

As a workaround I've defined the exact same transaction manager I already have defined in other configuration class in my Spring Batch configuration class. So my application starts defining my transaction manager, then gets overridden by Spring Batch transaction manager and then gets overridden by my second definition of the transaction manager.

Sweet.

Adding a @ConditionalOnMissingBean seems to be easy enough. Am I missing something? Why isn't this addressed already? It's open since 2014.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 25, 2018

Martin Meyer commented

I'm not sure what this magic @ConditionalOnMissingBean annotation is (I can't find Javadoc for it in Spring Framework or Spring Batch), but I've created a PR to try to address this issue:

#609

 

Basically I just try to autowire a transaction manager and make a new one only if there isn't one.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 31, 2018

Mahmoud Ben Hassine commented

This issue is resolved with #634.

In order to provide a custom transaction manager, a custom BatchConfigurer must be provided. For example:

@Bean
 public BatchConfigurer batchConfigurer() {
 	return new DefaultBatchConfigurer() {
 		@Override
 		public PlatformTransactionManager getTransactionManager() {
 			return new MyTransactionManager();
 		}
 	};
 }

Documentation was updated accordingly (See https://github.com/spring-projects/spring-batch/pull/620/files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.