2012-10-23 3 views
0

Grails 1.3.7을 실행하는 이전 프로젝트에서 도메인 클래스 (예 : Patients)를 새로 추가했습니다 (부울을 사용할 수 없으며 nullable이 true 임). 나는 응용 프로그램을 실행할 때Grails : Domain 클래스에 새 필드를 추가하면 충돌이 발생합니다.

class Hospital { 
    hasMany = [patients: Patient] 
    string name 

class Patient 
    string name 
    string address 
    boolean disabled // Added this new field 

, 쿼리는 이제 java.lang.IllegalArgumentException를 던졌습니다 병원에 속한 모든 환자를 얻을 수 있습니다. 새 필드를 제거 "사용 안 함"및 응용 프로그램이 잘 실행됩니다. 여기

def h = Hospital.get(20) 
h.patients // This causes error below. No error if I remove the new field in domain 

오류입니다 : 오류를 발생

기본적으로 코드가 아래에 유사하다

Stacktrace follows: 
java.lang.IllegalArgumentException 
    at com.x.model.Patient_$$_javassist_26.hashCode(Patient_$$_javassist_26.java) 
    at java.util.HashMap.put(HashMap.java:372) 
    at java.util.HashSet.add(HashSet.java:200) 
    at java.util.AbstractCollection.addAll(AbstractCollection.java:305) 
    at com.x.service.QueryService$_getPatientsByHospitals_closure13.doCall(QueryService.groovy:183) 
    at com.x.service.QueryService.getPatientsByHospitals(QueryService.groovy:180) 
    at com.x.service.QueryService$$FastClassByCGLIB$$a2fb92c6.invoke(<generated>) 
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) 
    at com.x.service.QueryService$$EnhancerByCGLIB$$6756b2a.getPatientsByHospitals(<generated>) 
    at com.x.service.QueryService$getPatientsHospitals.call(Unknown Source) 
    at com.x.service.PatientsOverviewService.createSummaryRow(PatientsOverviewService.groovy:366) 
    at com.x.service.PatientsOverviewService$_getPatientsSummaries_closure9.doCall(PatientsOverviewService.groovy:306) 
    at com.x.service.PatientsOverviewService.getPatientsSummaries(PatientsOverviewService.groovy:296) 
    at com.x.service.PatientsOverviewService$getPatientsSummaries.callCurrent(Unknown Source) 
    at com.x.service.PatientsOverviewService.getPatientsOverview(PatientsOverviewService.groovy:50) 
    at com.x.service.PatientsOverviewService$$FastClassByCGLIB$$15a92775.invoke(<generated>) 
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) 

com.x.ui.PatientsOverviewController $ _closure2.doCall (PatientsOverviewController.groovy) java.lang.Thread.run (Thread.java:662)

나는 어떤 도움이나 제안을 주셔서 감사합니다. 이것은 지금 몇 시간 동안 나를 괴롭 히고있다.

+2

당신이 쓸 수있는'boolean' 속성을 가질 수 없다면 대신'Boolean'을 사용해야합니다. –

+0

고마워요. 그것이 문제였습니다. – ibaralf

+0

답변에 댓글을 남겼습니다. –

답변

2

boolean과 같은 프리미티브 유형의 속성을 Nullable로 설정할 수 없으므로 대신 래퍼 클래스 (Boolean)를 사용해야합니다.

관련 문제