2012-03-14 586 views
0

我想测试groovy/grails的SQL查询。回顾为什么SQL插入不起作用,我试图打印出该查询行。令人惊讶的是,甚至没有这个工作,所以我正在调查groovy中的字符串格式。如果有人有线索,请告诉我。groovy字符串格式化

println """INSERT INTO iu (version, path, uuid, name, description, 
          sourceversionfrom, sourceversionexto, 
          targetversionfrom, targetversionexto, 
          phase, directive, classname, methodname, 
          functionalarea_id, upgradepath_id, date_created, 
          last_updated, mark4delete, firstAvailable_id, 
          lastAvailable_id, uniqueid_id, elementcreateddate, 
          purpose, implementationdetails, userimpact) 
       VALUES (${this.version}, ${this.path}, ${this.uuid}, ${this.name}, 
         ${this.description}, ${this.sourceversionfrom}, 
         ${this.sourceversionexto}, ${this.targetversionfrom}, 
         ${this.targetversionexto}, ${this.phase}, ${this.directive}, 
         ${this.classname}, ${this.methodname}, $functionalarea_id, 
         $upgradepath_id, NOW(), NOW(), 0, ${this.projID}, 
         ${this.projID}, ${this.uniqueid_id}, 
         ${this.getElementCreatedDate()}, ${this.purpose}, 
         ${this.implementationDetails}, ${this.userImpact})""" 

程序停止和该行

+0

你是什么意思_“程序暂停和待命”_?它崩溃?它没有打印出来并挂起?顺便说一句:你发布的代码看起来很好...... – 2012-03-14 14:06:54

回答

1

后表示通过这没有什么不对您的查询字符串。该程序可能挂在取回其中一个属性(versionpath,uuid等)通过吸气剂,或在getElementCreatedDate的电话。

要查看程序在挂起时执行的操作,可以生成线程转储。当在终端或控制台窗口中交互式运行groovy时,发送QUIT信号或在Linux或OS X上键入ctrl- \,或在Windows上键入ctrl-break。寻找"main"线程,并扫描堆栈跟踪,直到达到您自己的代码。

+0

函数$ {this.getElementCreatedDate()}是麻烦来源。我已经隔离了这个问题,它正在生成一个导致程序静止的NULL指针... – cybertextron 2012-03-15 15:39:16