1
因此,一直試圖在grails中運行搜索,並且無法弄清楚發生了什麼。grails在hasmany上的搜索
該應用程序有兩個域名,一個國家地圖(稱爲國家),第二個是註冊表,其中包含每個國家的數據。 我建立了這樣的國家有很多註冊商標,而註冊商標屬於國家。 (最後粘貼了定義)。所以,試圖在我根據國家和地區獲得註冊登記條目的情況下撥打電話。
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: [genm[email protected]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'
}
}
和Reg STAT
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(字符串SN,字符串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
我也試過。得到一個奇怪的錯誤,然後(更新原來的帖子與該錯誤信息) – vrghost 2014-10-08 09:58:46
我剛剛更新了我的答案。第84行的異常是關於查詢還是渲染? – Abincepto 2014-10-08 10:20:24
嘗試暫時不使用GPars - 您需要減少變量的數量(尤其是在無法使單線程查詢工作時運行多線程查詢...),以便您可以看到這種情況正在發生。 – 2014-10-08 10:27:38