Stop Grails from opening a connection to the database in a Controller method -
i have service communicating machine. since it's simple controller method grails automatically grabs db connection pool while controller communicating other server. i'd prevent doing that, , manually open database connection when i'm ready doesn't suck connection during long period doing network calls. how prevent grails automatically grabbing connection pool in controller method?
when create controller has transactional
annotation on it, like:
@transactional(readonly=true) class foocontroller { ..
if remove annotation (and method level annotations) grails no longer connect database start transaction.
open session in view should not come play since use lazy init approach obtaining connection osiv
note answer above assumes using recent version of grails (2.3.x or above)
updated
for mongodb can disable automatically connection controllers defining following bean (which overrides default) in grails-app/conf/spring/resources.groovy
:
mongopersistenceinterceptor(org.codehaus.groovy.grails.support.nullpersistentcontextinterceptor)
however there no way disable on per controller basis @ moment
Comments
Post a Comment