Skip to content

Instantly share code, notes, and snippets.

@gokhanakgul
Created January 7, 2014 19:23
Show Gist options
  • Save gokhanakgul/8305215 to your computer and use it in GitHub Desktop.
Save gokhanakgul/8305215 to your computer and use it in GitHub Desktop.
In a service or controller, you can add a dependency injection for the dataSource bean and use groovy.sql.Sql or JDBC directly if you're a masochist. :) by Burt Beckwith [http://stackoverflow.com/questions/4600729/grails-query-not-using-gorm/4600991#4600991]
import groovy.sql.Sql
class DataService {
def dataSource
void runQuery(...) {
def sql = new Sql(dataSource)
sql.eachRow('select * from foo') { row ->
...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment