[英]No value specified for parameter - Grails
在域類上使用查找方式時遇到問題:
我得到的錯誤是: ERROR util.JDBCExceptionReporter - No value specified for parameter 2
域類是:
class AppDetail {
String name
String url
Boolean active
static hasMany = [authString:AppIdentifier]
static constraints = {
name(unique:true,blank:false)
active(nullable:true)
}
class AppIdentifier {
Date added
String authString
static belongsTo = [authString:AppDetail]
static constraints = {
added()
authString(blank:false)
}
查找依據是:
def identifier = AppIdentifer.findByAuthString('test')
def appDetails = AppDetail.findByAuthString(identifier)
誰能提供有關此錯誤含義的任何見解?
提前致謝!
您有太多名為“ authString”的字段。 這是重做相同類的另一種方法:
class AppDetail {
String name
String url
Boolean active
static hasMany = [identifiers:AppIdentifier]
static constraints = {
name(unique:true,blank:false)
active(nullable:true)
}
class AppIdentifier {
Date added
String authString
static belongsTo = [appDetail:AppDetail]
static constraints = {
added()
authString(blank:false)
}
def identifier = AppIdentifer.findByAuthString('test')
def appDetails = identifier.appDetail
您將authString都定義為String和AppDetail:
String authString
static belongsTo = [authString:AppDetail]
刪除String authString
或將其更改為AppDetail authString
順便說一句,從GORM的角度來看,屬性命名並不重要。 但是,如果您在名稱中使用String
定義了一個屬性,而在另一個類中,則將來會遇到維護問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.