Grails:在域类中添加新字段会导致崩溃

Grails:在域类中添加新字段会导致崩溃,grails,gorm,grails-domain-class,Grails,Gorm,Grails Domain Class,我有一个运行Grails1.3.7的旧项目,在域类(例如Patients)中我添加了一个新字段(boolean disabled,nullable为true) 当我运行应用程序时,获取医院所有患者的查询现在抛出java.lang.IllegalArgumentException。删除新字段“disabled”,应用程序运行正常 基本上,导致错误的代码类似于以下代码: def h = Hospital.get(20) h.patients // This causes error below.

我有一个运行Grails1.3.7的旧项目,在域类(例如Patients)中我添加了一个新字段(boolean disabled,nullable为true)

当我运行应用程序时,获取医院所有患者的查询现在抛出java.lang.IllegalArgumentException。删除新字段“disabled”,应用程序运行正常

基本上,导致错误的代码类似于以下代码:

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)
Stacktrace如下:
java.lang.IllegalArgumentException
在com.x.model.Patient\u$$\ uJavassist\u26.hashCode(Patient\u$$\ uJavassist\u26.java)
位于java.util.HashMap.put(HashMap.java:372)
在java.util.HashSet.add处(HashSet.java:200)
位于java.util.AbstractCollection.addAll(AbstractCollection.java:305)
在com.x.service.QueryService$\u getPatientsByHospitals\u closure13.doCall(QueryService.groovy:183)
访问com.x.service.QueryService.getPatientsByHospitals(QueryService.groovy:180)
在com.x.service.QueryService$$FastClassByCGLIB$$a2fb92c6.invoke()上
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
在com.x.service.QueryService$$enhancerbyglib$$6756b2a.getPatientsByHospitals()上
访问com.x.service.QueryService$getPatientsHospitals.call(未知来源)
位于com.x.service.PatientsOverviewService.createSummaryRow(PatientsOverviewService.groovy:366)
在com.x.service.PatientsOverviewService$\u getPatientsSummaries\u closure9.doCall(PatientsOverviewService.groovy:306)
访问com.x.service.PatientsOverviewService.getPatientsSummaries(PatientsOverviewService.groovy:296)
在com.x.service.PatientsOverviewService$getPatientsSummaries.callCurrent(未知来源)
在com.x.service.PatientsOverviewService.getPatientsOverview(PatientsOverviewService.groovy:50)
在com.x.service.PatientsOverviewService$$FastClassByCGLIB$$15a92775.invoke()上
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
com.x.ui.PatientsOverviewController$\u closure2.doCall(PatientsOverviewController.groovy) 运行(Thread.java:662)


我感谢任何帮助或建议。这已经困扰了我几个小时了

基本类型的属性(如
boolean
)不能为空,您需要使用包装类(
boolean
)。

您不能有可为空的
boolean
属性,您需要使用
boolean
。非常感谢。这就是问题所在。我已经把这个评论变成了一个答案。
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)