Monday, September 13, 2010

Using the Grails Console

Thanks to Kwang Ho Lee for this

Using the console is very powerful, your console actually runs within your current
environment so it is a very powerful place to rapidly prototype code.

Start the console with something like this, allows you to attach to any environment
  @echo off
  set JAVA_OPTS=-Xmx1024m -XX:MaxPermSize=256m
  grails -Dgrails.env=dev console

Then from within the console you have access to domain objects and the service objects. Just import domain objects and do a getBean to obtain the service objects

  import domain.*
  def aService = grailsApplication.mainContext.getBean('aService')
  def dlr = Dealer.findByDealerId('XXX')
  def qs = aService.bigFinder(dlr)

No comments:

Post a Comment