2013-10-17 5 views
0

Grails에 다음과 같은 도메인 모델이 있습니다. 쿼리를 실행하려고하는데 잘못된 쿼리라고합니다.이 Grails (GORM) 쿼리가 유효하지 않은 이유는 무엇입니까?

StringBuilder queryBuf = new StringBuilder(); 
    queryBuf.append("select rr.role from ReportRole rr "); 
    def newroles = ReportRole.findAll(queryBuf) 

그리고이 도메인은 다음과 같이 :

쿼리처럼 보이는이 유효하지 않은 이유

package auth 

import java.util.Date 
import auth.Report 
import auth.Role 

class ReportRole { 
Long id 
Report report 
Role role 
Date dateCreated 
Date lastUpdated 
Person createdBy 

static mapping = { 
    table 'CIT_RM_Report_Role' 
    version false 
    role joinTable:[name:'AU_ROLE_DESCR', key:'role_id', column:'id'] 
    columns { 
     id column:'report_role_id' 
     report column:'report_id' 
     createdBy column:'created_by' 
     dateCreated column:'create_date' 
     lastUpdated column:'last_updated' 

     } 
    } 
} 

package auth; 
class Role { 
static hasMany = [people: Person] 
Long id; 
String authority; 
String description; 
static mapping = { 
    table 'AU_ROLE_DESCR' 
    people joinTable:[name:'AU_PERSON_ROLE', key:'AUTHORITY_ID', column:'PERSON_ID'] 
    version false; 
    } 
} 

사람은 말해 줄 수. 이 비슷한 쿼리가 작동하는 몇 가지 유사한 도메인이 있습니다.

+0

정확한 오류는 다음과 같습니다 : 당신은 더 나은 당신이 무엇을 추구 달성하기 위해 executeQuery를 사용하여 도메인 클래스에 대한 잘못된 쿼리 [ReportRole의 RR에서 선택 rr.role] [클래스 auth.ReportRole은] –

+0

내가 열쇠를했을 수 있습니다 생각/열이 섞여서 역전을 시도했지만 같은 오류가 발생했습니다. –

답변

2

findAll은 특정 연관/요소 대신 도메인 목록으로 돌아 가기 위해 제한된다고 가정합니다.

ReportRole.executeQuery("select rr.role from ReportRole rr") 
+0

트릭을 해 주셔서 감사합니다. –

관련 문제