Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
fix for GPMONGODB-184 "No transactionManger bean with NoSQL plugin bu…
Browse files Browse the repository at this point in the history
…t no Hibernate"
  • Loading branch information
graemerocher committed Apr 10, 2012
1 parent 547b54a commit 23bc12c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ abstract class SpringConfigurer {
datastore = ref("${typeLower}Datastore")
}

def currentSpringConfig = getSpringConfig()

if(!currentSpringConfig.containsBean("transactionManager") && !manager?.hasGrailsPlugin('hibernate')) {
currentSpringConfig.addAlias('transactionManager', "${typeLower}TransactionManager")
}

"${typeLower}PersistenceInterceptor"(DatastorePersistenceContextInterceptor, ref("${typeLower}Datastore"))

"${typeLower}PersistenceContextInterceptorAggregator"(PersistenceContextInterceptorAggregator)
Expand All @@ -74,10 +80,10 @@ abstract class SpringConfigurer {
"${interceptorName}"(OpenSessionInViewInterceptor) {
datastore = ref("${typeLower}Datastore")
}
if (getSpringConfig().containsBean("controllerHandlerMappings")) {
if (currentSpringConfig.containsBean("controllerHandlerMappings")) {
controllerHandlerMappings.interceptors << ref(interceptorName)
}
if (getSpringConfig().containsBean("annotationHandlerMapping")) {
if (currentSpringConfig.containsBean("annotationHandlerMapping")) {
if (annotationHandlerMapping.interceptors) {
annotationHandlerMapping.interceptors << ref(interceptorName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SpringConfigurerSpec extends Specification{
then:"The context contains the necessary beans"
ctx.containsBean("simpleDatastore")
ctx.containsBean("simpleTransactionManager")
ctx.containsBean("transactionManager")
ctx.containsBean("simplePersistenceInterceptor")
ctx.containsBean("simplePersistenceContextInterceptorAggregator")
ctx.containsBean("simpleOpenSessionInViewInterceptor")
Expand All @@ -32,7 +33,7 @@ class SpringConfigurerSpec extends Specification{
}
}
class SimpleSpringConfigurer extends SpringConfigurer {
Map manager = [hasGrailsPlugin:{ true }]
Map manager = [hasGrailsPlugin:{ String name -> name != 'hibernate' ? true : false }]
Map application = [:]
@Override
String getDatastoreType() {
Expand Down

0 comments on commit 23bc12c

Please sign in to comment.