2014-01-29 27 views
0

我使用域类找到时,有一个问题:的参数没有指定值 - 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) 

任何人都可以亲提供任何洞察这个错误的含义?

在此先感谢!

回答

0

您有太多名为“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 
0

您定义authString既作为字符串,AppDetail:

String authString 

static belongsTo = [authString:AppDetail] 

请删除String authString或将其更改为AppDetail authString

BTW从上看GORM的属性命名并不重要。但是如果你定义了一个名字为String的属性,但是另一个类别的属性,将来你会遇到维护问题。

相关问题