Grails + Mongodb + Spock:在进行嵌入式字段查询时抛出 NullPointerException
Grails + Mongodb + Spock: NullPointerException being thrown when doing embedded field query
在一项服务上,我正在尝试做类似的事情:
Organization.withCriteria {
eq( "active", true )
eq( "location.region", region)
}
正在工作 但是在单元测试中调用该方法时我得到:
java.lang.NullPointerException
at org.grails.datastore.mapping.keyvalue.mapping.config.KeyValuePersistentEntity.getPropertyByName(KeyValuePersistentEntity.java:75)
at grails.gorm.CriteriaBuilder.validatePropertyName(CriteriaBuilder.java:954)
at grails.gorm.CriteriaBuilder.eq(CriteriaBuilder.java:435)
at com.apposit.terra.connect.service.OrganizationService.getAllOrganizationsInZone_closure9(OrganizationService.groovy:322)
at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:980)
at grails.gorm.CriteriaBuilder.invokeMethod(CriteriaBuilder.java:314)
at org.grails.datastore.gorm.GormStaticApi.withCriteria_closure11(GormStaticApi.groovy:305)
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:304)
应该是:
Organization.withCriteria {
eq( "active", true )
location {
eq( "region", region)
}
}
提交 JIRA
在一项服务上,我正在尝试做类似的事情:
Organization.withCriteria {
eq( "active", true )
eq( "location.region", region)
}
正在工作 但是在单元测试中调用该方法时我得到:
java.lang.NullPointerException
at org.grails.datastore.mapping.keyvalue.mapping.config.KeyValuePersistentEntity.getPropertyByName(KeyValuePersistentEntity.java:75)
at grails.gorm.CriteriaBuilder.validatePropertyName(CriteriaBuilder.java:954)
at grails.gorm.CriteriaBuilder.eq(CriteriaBuilder.java:435)
at com.apposit.terra.connect.service.OrganizationService.getAllOrganizationsInZone_closure9(OrganizationService.groovy:322)
at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:980)
at grails.gorm.CriteriaBuilder.invokeMethod(CriteriaBuilder.java:314)
at org.grails.datastore.gorm.GormStaticApi.withCriteria_closure11(GormStaticApi.groovy:305)
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:304)
应该是:
Organization.withCriteria {
eq( "active", true )
location {
eq( "region", region)
}
}
提交 JIRA