Skip to content

Instantly share code, notes, and snippets.

View gokhanakgul's full-sized avatar

Gökhan Akgül gokhanakgul

View GitHub Profile
@gokhanakgul
gokhanakgul / restCurlPerfromance
Created January 13, 2014 10:16
Grails Rest performance calculation on shell
curl -X POST -d @file server:port -w %{time_connect}:%{time_starttransfer}:%{time_total}
curl -i -w %{time_connect}:%{time_starttransfer}:%{time_total} -H "Accept: application/json" localhost:8080/cms/api/menus
curl -s -w "%{time_total}\n" -H "Accept: application/json" localhost:8080/cms/api/menus
@gokhanakgul
gokhanakgul / JdbcService
Created January 7, 2014 19:23
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 ->
...
private void saveDomainClassProperties(String domainClassName, Map newProperties) {
log.info "domainClass : $domainClassName"
def domainClassInstance = grailsApplication.getDomainClass(domainClassName).newInstance()
domainClassInstance.properties = newProperties
domainClassInstance.save(flush: true)
}