Skip to content

Commit

Permalink
Remove bean transactionManager from DataSource plugin
Browse files Browse the repository at this point in the history
Closes gh-816
  • Loading branch information
rainboyan committed Dec 23, 2024
1 parent 264f167 commit d392e57
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -37,6 +38,7 @@
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.transaction.PlatformTransactionManager;

import grails.boot.config.GrailsComponentScanner;
import grails.config.Config;
Expand All @@ -60,6 +62,7 @@
* @author Michael Yan
* @since 2023.1
*/
@AutoConfigureOrder(200)
@AutoConfiguration(after = DataSourceAutoConfiguration.class,
before = { HibernateJpaAutoConfiguration.class, TransactionAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class})
@ConditionalOnClass(HibernateDatastore.class)
Expand Down Expand Up @@ -148,6 +151,12 @@ public MappingContext grailsDomainClassMappingContext(HibernateDatastore hiberna
return hibernateDatastore.getMappingContext();
}

@Bean
@ConditionalOnMissingBean
public PlatformTransactionManager transactionManager(HibernateDatastore hibernateDatastore) {
return hibernateDatastore.getTransactionManager();
}

@Bean
@ConditionalOnMissingBean
public AggregatePersistenceContextInterceptor persistenceInterceptor(HibernateDatastore hibernateDatastore) {
Expand Down

0 comments on commit d392e57

Please sign in to comment.