【发布时间】:2014-10-08 08:40:36
【问题描述】:
所以,一直试图在 grails 中运行搜索,但无法弄清楚发生了什么。
该应用程序有两个域,一个国家地图(称为国家),第二个是 regstat,其中包含每个国家/地区的数据。 我设置它以便国家有很多 regstat,并且 regstat 属于国家。 (最后粘贴了定义)。因此,尝试拨打电话,让我根据国家和地区获得 regstat 条目。
def countdata(String sn, String regsel) {
def cpp = Regstat.where {
domain { countryiso == sn } && reg == regsel
}
render cpp as JSON
}
给我以下错误信息。
/GenMap/getcountry/countdata
Class
groovy.lang.MissingMethodException
Message
No signature of method: grails.gorm.DetachedCriteria.domain() is applicable for argument types: (genmap.GetcountryController$_countdata_closure1_closure10_closure11) values: [genmap.GetcountryController$_countdata_closure1_closure10_closure11@5dbfaacf] Possible solutions: min(), join(java.lang.String), min(java.lang.String), join(java.lang.String), min(groovy.lang.Closure), min(java.util.Comparator)
我也尝试过使用国家
def countdata(String sn, String regsel) {
def cpp = Regstat.where {
country { countryiso == sn } && reg == regsel
}
render cpp as JSON
}
这给了我以下错误消息(在 JSON 网络返回中)
{"alias":null,"async":{"decorators":[{"class":"com.sun.proxy.$Proxy40"}],"gormOperations":{"_ref":"..","class":"grails.gorm.DetachedCriteria"},"persistentClass":{"internalPromise":{"bindErrorManager":{"bindErrorListeners":[],"class":"groovyx.gpars.dataflow.impl.DataflowChannelEventOrchestrator","listeners":[]},"bound":false,"error":false,"eventManager":{"bindErrorListeners":[],"class":"groovyx.gpars.dataflow.impl.DataflowChannelEventOrchestrator","listeners":[]}
所以有两个域。 一个是国家地图。
class Country {
static hasMany = [regstats: Regstat]
String countryiso
String countryname
static constraints = {
countryiso size:2..2, unique: true, validator:{ it.toUpperCase() == it }
}
static mapping = {
index: 'countryiso'
}
}
和注册统计
class Regstat {
static belongsTo = [country: Country]
String reg
int status
String exturl
Date impdate
Date lupdate
String impnote
static constraints = {
reg(inList: ["FATCA", "ITC2014", "AEOI"], unique:'country')
exturl(nullable:true)
impnote(nullable:true)
impdate(nullable:true)
}
static mapping = {
index: 'reg'
impnote type: 'text'
}
}
第一次回复后更新 也试过了
def countdata(String sn, String regsel) {
def cpp = Regstat.where {
country.countryiso == sn && reg == regsel
}
render cpp as JSON
}
收到以下错误消息(和乱码的 JSON 输出)
| Error 2014-10-08 10:56:24,532 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /GenMap/getcountry/countdata - parameters:
sn: RU
regsel: FATCA
Stacktrace follows:
Message: null
Line | Method
->> 82 | <init> in groovyx.gpars.serial.SerialHandle
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 41 | <init> in ''
| 174 | <init> . . . . . . . . in groovyx.gpars.serial.SerialHandle$LocalSerialHandle
| 172 | <init> in ''
| 165 | create . . . . . . . . in groovyx.gpars.serial.SerialHandle
| 62 | getOrCreateSerialHandle in groovyx.gpars.serial.WithSerialId
| 202 | value . . . . . . . . . in grails.converters.JSON
| 162 | convertAnother in ''
| 202 | value . . . . . . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . . . . . . in ''
| 162 | convertAnother in ''
| 202 | value . . . . . . . . . in ''
| 134 | render in ''
| 150 | render . . . . . . . . in ''
| 15 | countdata in genmap.GetcountryController$$EOs5m7Ro
| 198 | doFilter . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1142 | runWorker . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . in java.lang.Thread
【问题讨论】:
标签: grails grails-orm