Can you have code that looks like this?
def methodname ()
{
proc = "sql to call a stored proc"
def conn = Sql.newInstance(DB_CONN, DB_USERNAME, DB_PASSWORD, "org.postgresql.Driver")
def result1 = conn.rows(proc)
def result2 = MyClass.Find("from MyClass where foo='bar'")
return [result1, result2]
}
If so are they using different connections? Is there any way to get the call to the stored proc to use the same connection as the MyClass call?
They will use different connections. Sql will grab a new one and the GORM call will use one from the connection pool managed by the DataSource. But you can get Sql to use the same connection as the GORM call by using sessionFactory.currentSession.connection():