简体   繁体   English

没有为参数指定值-Grails

[英]No value specified for parameter - Grails

I'm having an issue when using a find by on a domain class: 在域类上使用查找方式时遇到问题:

The error I'm getting is: ERROR util.JDBCExceptionReporter - No value specified for parameter 2 我得到的错误是: ERROR util.JDBCExceptionReporter - No value specified for parameter 2

The domain classes are: 域类是:

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)

}

The find by is: 查找依据是:

def identifier = AppIdentifer.findByAuthString('test')
def appDetails = AppDetail.findByAuthString(identifier) 

Can anyone provide any insight into the meaning of this error? 谁能提供有关此错误含义的任何见解?

Thanks in advance! 提前致谢!

You have too many fields named "authString". 您有太多名为“ authString”的字段。 Here's another way to redo the same classes: 这是重做相同类的另一种方法:

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

You defined authString both as String AND AppDetail: 您将authString都定义为String和AppDetail:

String authString

static belongsTo = [authString:AppDetail]

Either remove String authString or change it to AppDetail authString 删除String authString或将其更改为AppDetail authString

BTW From the point of view of GORM the property naming doesn't matter. 顺便说一句,从GORM的角度来看,属性命名并不重要。 But if you define a property with String in it's name, but of another class, you gonna get maintenance problems in the future. 但是,如果您在名称中使用String定义了一个属性,而在另一个类中,则将来会遇到维护问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM