Open gabivis opened 4 years ago
@gabivis Did you find any solution for the same out of the box ?
@gabivis As work around we have overridden bean like below in project resources.groovy.
def domainClasses = grailsApplication.getArtefacts(DomainClassArtefactHandler.TYPE)
.findAll { it.mappingStrategy != "none" && it.mappingStrategy == GrailsDomainClass.GORM }
.collect { it.getClazz() }
hibernateConnectionSourceFactory(HibernateFilterConnectionSourceFactory, domainClasses as Class[]) {
dataSourceConnectionSourceFactory = ref('dataSourceConnectionSourceFactory')
}
to avoid recreation of another dataSourceConnectionSourceFactory.
Steps to Reproduce define a dataSource in application.groovy (I use tomcat jdbc connection pooling) dataSource { pooled= true username = password = ... properties { ... maxActive=16 testOnBorrow=true testWhileIdle=true
} } Reference the dataSource in a service class MyService { def dataSource def myMethod() { def sql = new Sql(dataSource) ... } } Expected Behaviour The datasource has the same custom properties as the ones set in application.groovy: i.e. testOnBorrow=true, testWhileIdle=true
Actual Behaviour The properties inside the properties block are ignored and so testOnBorrow=false, testWhileIdle=false
Environment Information Grails Version: 3.3.9 JDK Version: 1.8 Container Version (If Applicable): Tomcat