1
從Grails 2.2.4遷移到2.4.3後,在條件查詢中使用該屬性時,具有名爲applicationContext的屬性的域類會引發異常。'applicationContext'在Grails 2.4.3中被禁止作爲域屬性名嗎?
class WebResource {
String applicationContext
}
class ResourceService {
public WebResource getResourceByContext(String ctx) {
WebResource.withCriteria() {
eq('applicationContext', ctx)
}
}
}
到getResourceByContext(A調用)拋出一個異常:
用 '的applicationContext' 不允許的Grails 2.4.3名稱org.hibernate.QueryException: could not resolve property: applicationContext of: org.mydomain.WebResource at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1995) at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:61) at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1970) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:518) at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:534) at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:82) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:417) at org.hibernate.loader.criteria.CriteriaJoinWalker.(CriteriaJoinWalker.java:123) at org.hibernate.loader.criteria.CriteriaJoinWalker.(CriteriaJoinWalker.java:92) at org.hibernate.loader.criteria.CriteriaLoader.(CriteriaLoader.java:97) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1663) at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380) at org.codehaus.groovy.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.invokeMethod(AbstractHibernateCriteriaBuilder.java:1639) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:907) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:884) at org.grails.datastore.gorm.GormStaticApi$_withCriteria_closure11.doCall(GormStaticApi.groovy:304) at sun.reflect.GeneratedMethodAccessor254.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51) at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:81) at com.sun.proxy.$Proxy29.doInSession(Unknown Source) at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:302) at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37) at org.grails.datastore.gorm.GormStaticApi.withCriteria(GormStaticApi.groovy:303) at org.mydomain.WebResource.withCriteria(WebResource.groovy)
是具有域屬性?我無法在Grails發行說明,升級指南或JIRA中找到對此方案的引用。我已經通過重命名字段,GORM改變引用新名稱解決此問題的工作:
class WebResource {
String appContext
appContext column: 'APPLICATION_CONTEXT'
public String getApplicationContext() {
return appContext
}
public void setApplicationContext(String c) {
appContext = c
}
}