2012-03-14 2 views
0

groovy/grails에 대한 SQL 쿼리를 테스트하려고합니다. SQL 인서트가 작동하지 않는 이유는 무엇입니까? 나는 그 쿼리 라인을 인쇄하려고합니다. 놀랍지 만 그 작업조차도 아니므로 그루비에서 문자열 형식을 조사하고 있습니다. 누군가 그것에 대한 단서가 있다면 알려주십시오.groovy string formatting

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

_ "프로그램이 멈추고"_? 그것은 추락합니까? 아무것도 출력하지 않고 멈 춥니 다. BTW : 게시 된 코드가 나에게 잘 어울립니다 ... –

답변

1

후 대기 쿼리 문자열 아무 문제가 없습니다. getter를 통해 또는 getElementCreatedDate에 대한 호출로 속성 (version, path, 등) 중 하나를 검색 할 때 프로그램이 중단 될 수 있습니다.

프로그램이 멈출 때 어떤 작업을하는지 보려면 스레드 덤프를 생성하십시오. 터미널이나 콘솔 창에서 그루비가 대화식으로 실행될 때 QUIT 신호를 보내거나 Linux에서 OSX 또는 ctrl- \을 입력하거나 Windows에서 ctrl-break을 입력하십시오. "main" 스레드를 찾고 자신의 코드에 도달 할 때까지 스택 추적을 스캔하십시오.

+0

$ {this.getElementCreatedDate()} 함수는 문제의 원인입니다. 나는 문제를 고립시켰다. 프로그램을 멈추게하는 NULL 포인터를 생성하고있다. – cybertextron