Aiden Zhao Aiden Zhao - 4 months ago 25
Groovy Question

Should I close the groovy Sql in Grails service

I'm using groovy Sql in a Grails project.

class MyService{
def sessionFactory
def method(){
def sql = new Sql(sessionFactory.currentSession.connection())
def query =...

I see a lot of examples online about groovy sql in grails. All of them are not including the
in their code.

I'm wondering why. Is it because Grails has already managed the session connection after a service method is executed?
If so can you give me some evidence(or resources) I can refer to?


This is not necessary. Please refer to Does groovy.sql.Sql.firstRow Closes Connection After Execution?

Take a look at the link provided in the comments of the question by dmahapatro